Removing a validator with jQuery
Asked Answered
R

1

8

So I've added a validator dynamically to my page with the following code:

$.validator.unobtrusive.adapters.addBool('zipcode', 'validate_zipcode');

Is there a way to dynamically remove it? Something like:

$.validator.unobtrusive.adapters.removeBool('zipcode', 'validate_zipcode');

I've searched Google for something like this but can't find any reference to a remove method.

Royo answered 11/2, 2011 at 16:6 Comment(0)
F
9

Nothing built in, but you can do it via the jQuery validate API

$('#zipcode').rules('remove', 'validate_zipcode');
Flavorsome answered 11/2, 2011 at 16:17 Comment(1)
Is there also a way to add/remove methods on the fly (similar to rules)? I've got a big pile of custom methods I'd love to swap in/out based on user input and would like to reference them like a rule... but it doesn't seem to be working. :SClassify

© 2022 - 2024 — McMap. All rights reserved.