views:

103

answers:

2

I have a form which I post back via jQuery AJAX. In my controller it checks for errors in the ModelState and returns these errors in a ContentResult and the user sees the errors in an updated DIV.

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

Thanks

A: 

It's just a class name. input-validation-error. You can use jquery to parse the result for error properties and add the class to the appropriate elements.

Matt Hinze
At what point are the inputs created though? At the point of the AJAX post I don't think the inputs will have been created.
Jon
+1  A: 

I have returned the modelstate as a JSON object. The on the OnSuccess event I loop through the errors and find a span with the modelstate key name and set it to visible.

Jon