As above, I do not perform a client-side check, and if necessary, issue appropriate messages. However, the submit button still appears on the form, even if the form is not in a valid state.
The controller method returns it immediately because the ModelState is not valid, but is there a flag / property that I can check on the client side to prevent the message from appearing at all?
UPDATE: The problem is that the form is submitted asynchronously using a jquery message, so my javascript method publishes the data regardless of the validation state. So what I am looking for before I make this message is to do something in accordance with if( [Property/Method which indicates MVC Model State] == false ) return false;, however, I am struggling to find such a method or property.
I considered applying a validation function that identifies whether the input-validation-error class applies to any of my form fields. With jQuery, this is pretty simple, but I don't like it. Does anyone have any opinions on this?
On the one hand, this seems a bit hacked because I am effectively repeating the form after it has been verified to verify that it is valid. On the other hand, I’m not sure how MVC JS will identify the model state if there were several forms on one page, whereas if I did this myself, I could define “for the message of this form, I”, m is interested in these fields .
Gavin source
share