New to xVal and MVC, so please forgive me if this is a simple problem.
Given a domain model class with DataAnnotation attributes - let's just say Required for now - I have no problem using xVal validation under its default settings to validate things such as dropdowns, textboxes, etc on both the client and server side.
To simplify the discussion, please assume that my model object has a String property named "MyGroup", and that it is marked as required. If I throw a text field on the page, no problem - everything binds as I would expect. However,
assume for a minute I have a group of radio buttons like this:
<input type="radio" name="MyGroup" value="A1" />A1<br/>
<input type="radio" name="MyGroup" value="A2" />A2<br/>
<input type="radio" name="MyGroup" value="A3" />A3<br/>
<input type="radio" name="MyGroup" value="A4" />A4<br/>
<input type="radio" name="MyGroup" value="A5" />A5<br/>
Using ASP.NET MVC2, VS2010 Ultimate Beta 2 and xVal, I cannot get the validation to fire for this! (Yes, I realize a radio group for a string property is... odd. But I'll hold off on my enum question for later. :-) ). I have seen
the jQuery Validation demo with radio groups, and if I add this to my document.ready function:
Then I get a different effect - the validation "works", although it's no longer using the typical CSS, doesn't use my validationSummary client-side, etc (presumably because with that call I have bypassed xVal?? Really not sure, I'm still
very new to this).
Can someone give me a working example for how you take a radio group, using ASP.NET MVC 2 and xVal, and validate that a selection has been provided?