邮箱、手机号、QQ号正则表达式

前端之家收集整理的这篇文章主要介绍了邮箱、手机号、QQ号正则表达式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

/**

* @date 2014/04/18

* @author wzj

* guestbook data check

*

**/

function checkForm()

{

var gosubmit = true;

//email check

var email = document.getElementById("email");

if(email.value != '')

{

if(!(/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/).test(email.value))

{

alert('请输入有效的邮箱地址!');

email.focus();

gosubmit = false;

}

}

//telephone check

var tel = document.getElementById("tel");

if(!(/^1[3|4|5|8][0-9]\d{4,8}$/).test(tel.value))

{

alert('请输入有效的手机号!');

tel.focus();

gosubmit = false;

}

//qq check

var qq = document.getElementById("qq");

if(qq.value != '')

{

if(!(/^\d[1-9]{5,10}$/).test(qq.value))

{

alert('请输入有效的QQ号!');

qq.focus();

gosubmit = false;

}

}

return gosubmit;

}

<form action = "#" onsubmit = "return checkForm" method="post">

<input id = "email" type="text" />

<input id = "tel" type="text" />

<input id = "qq" type="text" />

</form>

猜你在找的正则表达式相关文章