验证价格(只允许整数或小数):
<asp:RegularExpressionValidator ID="rev_price" runat="server" ControlToValidate="price" ValidationExpression="^(\d)+(\.\d+)?$" ErrorMessage="价格只能是数字"></asp:RegularExpressionValidator>
验证邮箱 格式:faron@163.com
<asp:RegularExpressionValidator ID="rev_email" runat="server" ControlToValidate="email" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="邮箱格式不正确"></asp:RegularExpressionValidator>
验证电话号码 格式:0571-88888888,13088888888
<asp:RegularExpressionValidator ID="rev_tel" runat="server" ControlToValidate="tel" ValidationExpression="(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)" ErrorMessage="电话号码格式不正确"></asp:RegularExpressionValidator>
限制输入字符长度范围 如:1-50个字符以内
<asp:RegularExpressionValidator ID="rev_title" runat="server" Display="Dynamic" ControlToValidate="title" ValidationExpression="(\w|\W){1,50}" ErrorMessage="长度应该在50个字符以内"></asp:RegularExpressionValidator>
限制输入整数范围 如:数字范围1-99
<asp:RangeValidator ID="rv_day" runat="server" ControlToValidate="day" MinimumValue="1" MaximumValue="99" Type="Integer" ErrorMessage="数字应该为1-99"></asp:RangeValidator>
验证网址 格式:www.163.com 163.com
<asp:RegularExpressionValidator ID="rev_homepage" runat="server" Display="Dynamic" ControlToValidate="homepage" ValidationExpression="([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" ErrorMessage="主页格式不正确"></asp:RegularExpressionValidator>