How to highlight Html.ValidationMessage on AJAX Post?

I have a form that I am submitting back via jQuery AJAX. In my controller, it checks for errors in ModelState and returns those errors in ContentResult and the user sees errors in the updated DIV.

How can I get the small * next to the fields when there are errors?

thanks

0


a source to share


2 answers


I returned the model state as a JSON object. In the OnSuccess event, I go through the errors and find the dip with the model name of the model and set it to visible.



+1


a source


It's just the name of the class. input-validation-error

... You can use jquery to parse the result for the error properties and add a class to the appropriate elements.



0


a source







All Articles