We using jquery input mask from here and a code snippet that sets and unsets the mask when necessary:
$('input.maskedInput').focus(function () {
$(this).mask("999-999-9999");
}).blur(function () {
var numbers = $(this).val().replace(/-/g, '').replace(/_/g, '');
$(this).val(numbers.toString()).unmask();
});
This worked fine with jquery 1.3.2 but when upgraded to 1.8.2 it stopped unmasking when user leaves the field with no errors. What needs to be adjusted so it starts unmasking again?
The problem is that you remove blur handler (by calling
unmask) attached by plugin inside another blur handler. To avoid unpredictable behaviour jQuery locally saves references to all handlers before running any of them.I have no idea why this code works with jq1.3.2.
To avoid this you can stop immediate propagation of blur event. http://api.jquery.com/event.stopImmediatePropagation/
http://jsfiddle.net/tarabyte/XgYSz/