日期:2014-05-18  浏览次数:20398 次

关于文本框输入问题
我在文本框中输入一串数字,
我想在输入到第五位得时候显示是否何规定得数值一致。
我应该怎么做,最好有适量得代码说明。

------解决方案--------------------
\d{4}你给定的数\d*

------解决方案--------------------
.aspx
<asp:TextBox ID= "tb " runat= "server " />

.cs
tb.Attributes.Add( "onkeyup ", "check(this) ");

js:
function check(o)
{
if (o.value.length == 5)
{
//检查
}
}

------解决方案--------------------
if (o.value.length == 5)
==============>
if (o.value.length % 5 == 0)
------解决方案--------------------
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<asp:RegularExpressionValidator ID= "RegularExpressionValidator1 " runat= "server " ControlToValidate= "TextBox1 "
ErrorMessage= "第五位必须是5... " ValidationExpression= "\d{4}5\d* "> </asp:RegularExpressionValidator>
<asp:Button ID= "Button1 " runat= "server " Text= "Button " />