开发者

How can i make the user to enter limited text in a text box?

in my application (asp.net) i have a filed ( phone code) and 开发者_StackOverflow社区 it contain a text box. and i want to restrict the user to enter only 4 letter after that the cursor should not print any character how can i write the code can u help me thank you


For an HTML text box

<input type="text" maxlength="4" runat="server" id="txt1" />

For an asp.net text box

<asp:TextBox ID="txt1" runat="server" MaxLength="4"></asp:TextBox>


Use the 'maxLength' property.

<asp:textbox maxlength="4" runat="server" />

Full msdn documentation on the property: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.maxlength(v=VS.100).aspx


<asp:TextBox ID="textBox1" runat="server" MaxLength="4"></asp:TextBox>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜