RequiredIfFalse

Sep 18, 2010 at 1:26 PM

Hello,

The attribute [RequiredIfFalse] works in server-side validation but not in client side with JQuery.

Thank you for the great effort.

Sep 18, 2010 at 1:51 PM

I checked the situation with MVC validation as well. Like it is in JQuery, RequiredIfFalse is not working in client side.

That's because in the javascript code of RequiredIf if the checkbox is not found as checked, no value is set to dependentValue variable, and with its default null value the function returns with true.

    if (dependentPropertyElement.length > 1) {
        for (var index = 0; index != dependentPropertyElement.length; index++)
            if (dependentPropertyElement[index]["checked"]) {
                dependentValue = dependentPropertyElement[index].value;
                break;
            }

        if (dependentValue == null)
            return true;

 

 

 
 

Coordinator
Sep 20, 2010 at 4:25 PM
Edited Sep 27, 2010 at 8:13 PM

Looking back at this code, I'm near certain this should have been:

 

if (dependentValue == null)
    dependentValue = false;

 

Try changing that bit of code and see if it helps - please let me know your results.

I'm going to write a couple of tests to make sure this doesn't break anything, then I'll make the change in source control. 

Coordinator
Sep 20, 2010 at 5:09 PM

I update the JS files and the JS unit tests. You can get the new JS files in this change set: 

http://foolproof.codeplex.com/SourceControl/changeset/changes/61253