Given a text field that is masked using the Masked Input plugin and marked as a required field by the validation plugin, consider the following
If you put focus in a text field that is masked, leave it without entering any information (or do not enter enough information to satisfy the mask), the masked input plugin will delete everything, leaving you with an empty text field.
$("#phoneNumber").mask("(999) 999-9999? x999999"); $("#sampleForm").validate({ rules: { phoneNumber: "required" } });
The validation plugin fires its blur event to a masked input plugin. This leads to checking the passage of the text field (since it has text), then the connected input plugin masks and deletes the text. The field must be marked as invalid once it has lost focus.
I tried using the regex checker. It is approaching, but again, since it starts before the masked input plugin clears the field, it shows an error when it should not (although the error disappears when the user tries to submit the form).
I also tried this:
$('input').bind('unmasked.maskedInput', function () { $(this).valid(); });
This works, but also interferes with the initial behavior of the validator: the fields are not checked until the submit button is pressed, after which they are checked when they lose focus.
I installed jsFiddle , which depicts the problems I encountered.
source share