代码如下:
js
function QQ(id,k)
{
var i=document.getElementById(id);
if(!k.test(i))
{
if(id=="QQId")
{
alert("QQ格式错误或账号位数不对!!!");
}
if(id=="QQpass")
{
alert("密码格式错误或位数不对!!!");
}
}
}
html
<div style=" margin-top:10px">
<li style=" list-style:none; width:160px; margin:0px auto; font-size:12px; height:40px">QQ号码:<input type="text" class="input" id="QQId" onblur="QQ('QQId',/^[1-9][0-9]{3,9}$/)" /></li>
<li style=" list-style:none; width:160px; margin:0px auto; font-size:12px; height:30px">QQ密码:<input type="text" class="input" id="QQpass" onblur="QQ('QQpass',/^([a-zA-Z]{1,}\w){6,12}$/)"/> </li>
<img src="images/btn_login.gif" style=" margin-left:110px" />
<p style=" font-size:12px; margin:10px 5px; line-height:25px"> 世界的改变不是少数人做了很多,而是每个人都做了一点点。伸出手,让我们把爱传递。</p>
</div>
不知道正则表达式作为参数时该怎么用?
温温酱
相关分类