RequiredIf fails on client side with radio buttons.

Jan 4, 2011 at 3:38 PM

Hi I have the following. 

 

//Model
public String rdoAppTypeOptions { get; set; }


[RequiredIf("rdoAppTypeOptions", "This is One", ErrorMessage = "Please select one option")]
public string rdoSelfFundingOptions { get; set; }


//View
<td> 
Yes&#160;<%: Html.RadioButtonFor(model => model.rdoSelfFundingOptions, "Yes") %>&#160;&#160; 
 No&#160;<%: Html.RadioButtonFor(model => model.rdoSelfFundingOptions, "No") %>
<%: Html.ValidationMessageFor(model => model.rdoSelfFundingOptions) %>
</td>

When "This is One" option is selected on the radio button rdoAppTypeOptions, the value of the rdoSelfFundingOption is always yes, whether if it is selected or not, and then the validation on the client side fails, but it comes back from the server, therefore the validation is applied but not on the client side.

Does anyone had this issue before? if so, How did you fixed?

Thanks in advance.

Cesar.