0

i'm using this solution An ASP.NET MVC validator to make sure at least one checkbox is checked to have at least one checkbox checked on my form. But i can't figure out how to display the error message, in unobstrusive.

I suppose i should use a ValidationMessageFor with a custom script for the client side.

4
  • This helped me when I was doing a similar thing: http://odetocode.com/Blogs/scott/archive/2011/02/22/custom-data-annotation-validator-part-ii-client-code.aspx Commented Feb 4, 2014 at 16:50
  • One of the thing i don't understand, is how i'm supposed to show the validation message. Usualy i use a ValidationMessageFor with the name of the propertie. But this time, my validator is not bound to a property, but independant and verifying several properties Commented Feb 4, 2014 at 17:05
  • If you look at the first part of the guide I linked to, you'll see that the property that needs to be validated is given the custom attribute [GreaterThan]. In the 2nd part you can see how the attribute implements IClientValidatable for use unobtrusively, then there is script to add to jQuery.validator so jquery knows what message to show. Commented Feb 4, 2014 at 17:16
  • You can use @html.ValidationMessage("ErrorMessage"). When your page is rendered, it will display whatever message that is stored in the variable "ErrorMEssage" Commented Feb 4, 2014 at 17:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.