jquerymaskedinput

using jquery masked input for updating values


i have a problem with masked input plugin. in my header i have

$("#isNo").mask("(999) 999-9999");

and my input field is;

<h:inputText value="#{bBean.PhoneNr}" id="isNo" />

so, when bBean.PhoneNr is empty, there is no problem, because textbox is rendered with null value in it. mask is successful. But when bBean.PhoneNr is something like 5123123123, if i dont click that text field, value remains same = 5123123123. if i click that text field it becomes (512) 312-3123. do you have an idea to correct that value to be masked before textbox clicking?


Solution

  • Try to fire 'click' event programmatically:

    $(document).ready(function() {
       $("#isNo").mask("(999) 999-9999").click();
    });