This is my field with mask:
$('#Cellphone').mask("(99)9999-9999?9", { placeholder: " " });
I want to clear the mask when my input lost its focus. Is there a way to do it? Something like an option of the plugin...
$('#Cellphone').mask("(99)9999-9999?9", { placeholder: " ", clearOnLostFocus: true });
or into a blur function:
$('#Cellphone').blur(function() { // clear the mask here. });
I want to change my mask dynamically. I'm using this function, and works pretty good...
$('#Cellphone').keyup(function () { var newValue = $(this).val() .replace("(", "") .replace(")", "") .replace(" ", "") .replace("-", "") .replace("?", ""); if (newValue.length > 10) { $(this).mask("(99)9-9999-9999", { placeholder: " " }); } });
BUT... When I press backspace with the content of this field selected, my mask stops to work. Any idea why this is happening?
Thank you, guys!