标签:java ext get os javascript html
JavaScript表单验证email邮箱,判断一个输入量是否为邮箱email,通过正则表达式实现。
//检查email邮箱
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>JavaScript表单验证email邮箱</TITLE>
</HEAD>
<BODY>
<script language="javascript">
function check(){
var email=document.getElementById("email").value;
var isemail=/^\w+([-\.]\w+)*@\w+([\.-]\w+)*\.\w{2,4}$/;
if (email=="") {
alert("请输入您的邮箱!");
return false;
}
if (email.length>25){
alert("长度太长");
return false
}
if (!isemail.test(email)){
alert("不是邮箱");
return false;
}
}
</script>
<FORM METHOD=POST ACTION="" onsubmit="return check()">
<INPUT TYPE="text" NAME="email"><INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>
标签:java ext get os javascript html
原文地址:http://www.cnblogs.com/hr2014/p/3810702.html