Jquery validator reset $.validator.setDefaults({ o

2020-02-13 06:40发布

问题:

are there any way to reset $.validator.setDefaults({ onfocusout: false, onkeyup: false }); in MVC3. I want to change the value in to some thing like $.validator.setDefaults({ onfocusout: true, onkeyup: true }); after I click a button. How to archive this? Thanks.

回答1:

setDefaults should be set before $('form').validate() is called. Once validate() is called, the default are not used, so you must update the instance settings:

var settings = $('form').validate().settings;
settings.onkeyup = ...

(answer by bruce:link answer)