c# - Is there any way to check ModelState.IsValid on page load BEFORE the form is submitted? -


so added required field our form our users submit , able edit. if user open form edit it, there new required field, works fine. if try submit form, model error displays saying need fill out. fine.

but have no indication field required. far know, modelstate.isvalid triggers on form post. there anyway call right on page load can see right away need fill out new field?

what asking should managed model in mvc pattern.

you can use framework client validation, recommended on comments, or elaborate own client validation.

just keep in mind model need communicate view fields mandatory, view can translate information user through ui.

you can in way want it: using different styles mandatory fields (which not option), programming validation rules throw message when mandatory field left empty, adding text explains field mandatory, etc...


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -