There is a document type field, and the document number field when you select a specific document type from the document type field on the document number field should display the N symbol automatically with a mask. And I have the other way around N being displayed only after entering. What is the problem? Share thoughts. Thanks in advance !

$("#<%=PC%>_DocType").live('change', function () { $('#<%=PC%>_PassNumber').val(''); var docType = this.value; if (docType == 1) { $("#<%=PC%>_PassNumber").unmask(); $("#<%=PC%>_PassNumber").mask("N?9999?9999"); } else if (docType == 49) { $("#<%=PC%>_PassNumber").unmask(); $("#<%=PC%>_PassNumber").mask("A?9999?9999"); } else if (docType == 2) { $("#<%=PC%>_PassNumber").unmask(); $("#<%=PC%>_PassNumber").mask("99999?9999"); } else (docType == 4) { $("#<%=PC%>_PassNumber").unmask(); $("#<%=PC%>_PassNumber").mask("99999?9999"); } } 
  • No Code Can't Help - ThisMan

1 answer 1

Replace change with a universal event input : https://developer.mozilla.org/en/docs/Web/API/GlobalEventHandlers/oninput

The event is triggered every time the field contents change, and not only when you switch focus (as does change).