Using depends with the jQuery Validation plugin

前端 未结 8 507
[愿得一人]
[愿得一人] 2021-01-12 11:52

I\'ve got a form with a bunch of textboxes that are disabled by default, then enabled by use of a checkbox next to each one.

When enabled, the values in these textbo

8条回答
  •  一整个雨季
    2021-01-12 12:50

    Using the "ignore" option (http://docs.jquery.com/Plugins/Validation/validate#toptions) might be the easiest way for you to deal with this. Depends on what else you have on the form. For i.e. you wouldn't filter on disabled items if you had other controls that were disabled but you still needed to validate for some reason. However, if that route doesn't work, using an additional class to filter on (adding and removing with your checkboxes) should get you to where you want to go, but easier.

    I.e.

            $('form').validate({
                ignore: ":disabled",
                ...
            });
    

提交回复
热议问题