如想限定为邮箱格式,只能为数字,只能为汉字,只能为英文等。服务器控件好像是可以用自带的验证控件+正则表达式搞定。可是html控件该怎么办到呢??求教!!
1 回答

繁星coding
TA贡献1797条经验 获得超4个赞
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>无标题文档</title>
<script>
function checkEmail(){
var re = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var email=document.getElementById('email').value;
if(email!=null && email.length>0){
if(re.test(email))
{
alert("Thanks,你输入的Email合法!");
}
else
{
alert("Sorry,你输入的Email不合法!");
添加回答
举报
0/150
提交
取消