I am goting to use this plugin for an asp.net textbox.
The textbox is:
<asp:TextBox ID="txtBox" runat="server" Text='<%# Bind("Phone") %>' />
I want the format is (999) 999-9999 when the textbox is non-empty. But it is null when the textbox is empty.
I want to select different mask by the text.
How is the code like?
I tried below:
Thanks.
jQuery(function($){
if(document.getElementById("<%# txtBox.ClientID %>")).innerText =
$("<%# txtBox.ClientID %>").mask("(999) 999-9999");
else
$("<%# txtBox.ClientID %>").mask("");
});
UPDATE
The textbox is inside a gridview. It likes:
<asp:TemplateField HeaderText="OrgContactPhone" SortExpression="OrgContactPhone">
<EditItemTemplate>
<asp:TextBox ID="txtBox" runat="server" Text='<%# Bind("OrgContactPhone") %>' MaxLength="50">
</asp:TextBox>
1 Answer