Is there a function in jquery.validate that will reset a single field like resetForm does for a form?

后端 未结 6 2327
旧巷少年郎
旧巷少年郎 2021-02-18 15:59

I want to call a jquery function to manually remove errors from a single field and reset the error markup. Is there a function that does this that would be similar to the reset

6条回答
  •  感动是毒
    2021-02-18 16:27

    var form = $('#form'); 
    var validator = form.validate();
    
    // Validate single field from that form.
    var myfield = $('#myfield');
    myfield.removeData('previousValue').removeAttr('aria-invalid');
    validator.resetElements(myfield);                         
    

提交回复
热议问题