求几个正则表达式在javascript中应用的小例子。谢谢。
function checkinput()
{
if (!test_Password(theForm.ctl00$ContentPlaceHolder1$txt_pwd.value))
{
alert('密码最小长度为 6 位!最大长度16位!');
theForm.ctl00$ContentPlaceHolder1$txt_pwd.focus();
return false;
}
function test_Password(strInput)
{
var myReg = /^[^\n,]{6,16}$/;
if (myReg.test(strInput)) return true;
return false;
}
}
<asp:Button ID="btn_save" class="newbutton03" runat="server" Text="注册" Width="101px" Height="30px" OnClick="btn_save_Click" OnClientClick="return checkinput();" />
- 上一篇: javascript正则表达式
- 下一篇: 返回列表