如何判断RegularExpressionValidator
这样的,文本框(txtPhone)的格式是数字型的,我数入了不正确的格式时,当单击"提交"按钮时,光标应跳到文本框(txtPhone),请问怎么用RegularExpressionValidator判断,(txtCoHKPhone.Attributes["onFoucs"] = "this.select()";txtCoHKPhone.Focus();) --------------------编程问答-------------------- 用js+正则吧,容易实现了 --------------------编程问答--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--------------------编程问答-------------------- 用这个呀
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="错误" SetFocusOnError="True" ValidationExpression="\d+"></asp:RegularExpressionValidator>
<asp:Button ID="Button1" runat="server" Text="submit" /></div>
</form>
</body>
</html>
<ajaxToolkit:FilteredTextBoxExtender runat="server" ID="FilteredTextBoxExtender5"
FilterType="numbers" TargetControlID="txtFromSortEdit">
这样就只能输入数字了,省得判断.
非常实用的. --------------------编程问答-------------------- var endnum=document.getElementById("Text_end").value;
var reg=/^[+-]?\d*$/;
if(!reg.exec(startnum))
{
alert("输入不合法");
return false;
}
补充:.NET技术 , ASP.NET