How can I enable jquery validation on readonly fields?

前端 未结 4 726
遇见更好的自我
遇见更好的自我 2020-11-30 09:41

Guys from http://jqueryvalidation.org/ just released version 1.13.1. Checking on their website i see this on the changelog:

CORE: * Ignore readonly as well as disabl

4条回答
  •  借酒劲吻你
    2020-11-30 10:19

    Thank you for you suggestion Panoptik, adding readonly on focusin, and then removing it on focusout was the cleanest way, million thanks! I answer myself in case anyone has the same problem. Hope it helps.

    $(document).on("focusin", "#someid", function() {
       $(this).prop('readonly', true);  
    });
    
    $(document).on("focusout", "#someid", function() {
       $(this).prop('readonly', false); 
    });
    

提交回复
热议问题