<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function validateform() {
var Emailname = document.getElementById("Emailname").value;
var birthday = document.getElementById("birthday").value;
var reg = /^\w+@\w+(\.\w+){1,2}$/;
var str = /^\d{2,4}-(0?[1-9]|1[0-2])-(0?[1-9]|[1-2][0-9]|3[0-1])$/;
if(reg.test(Emailname)) {
//document.getElementById("errorforEmailname").innerHTML = "电子邮件输入正确";
}else{
document.getElementById("errorforEmailname").innerHTML = "电子邮件输入错误";
document.getElementById("Emailname").focus();
return false;
}
if(str.test(birthday)) {
//document.getElementById("errorforbirth").innerHTML = "出生日期输入正确";
}else{
document.getElementById("errorforbirth").innerHTML = "出生日期输入不正确";
document.getElementById("birthday").focus();
return false;
}
return true;
}
function clearError(element){
document.getElementById(element).innerHTML = "";
}
</script>
</head>
<body>
<noscript>
提示:您的浏览器不支持或禁止了网页脚本,无法正常注册
</noscript>
<form id="myform" οnsubmit="return validateform()" action="validate.jsp" method="post">
E_mail: <input type="text" name="" id="Emailname" οnkeydοwn="clearError('errorforEmailname')" οnblur="validateform()"/>
<span style="color:red" id="errorforEmailname"></span>
<br/>
Birthday: <input type="text" name="" id="birthday" οnkeydοwn="clearError('errorforbirth')" οnblur="validateform()"/>(日期格式:1990-04-10)
<span style="color:red" id="errorforbirth"></span>
<br/>
<input type="submit" value="保存"/>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function validateform() {
var Emailname = document.getElementById("Emailname").value;
var birthday = document.getElementById("birthday").value;
var reg = /^\w+@\w+(\.\w+){1,2}$/;
var str = /^\d{2,4}-(0?[1-9]|1[0-2])-(0?[1-9]|[1-2][0-9]|3[0-1])$/;
if(reg.test(Emailname)) {
//document.getElementById("errorforEmailname").innerHTML = "电子邮件输入正确";
}else{
document.getElementById("errorforEmailname").innerHTML = "电子邮件输入错误";
document.getElementById("Emailname").focus();
return false;
}
if(str.test(birthday)) {
//document.getElementById("errorforbirth").innerHTML = "出生日期输入正确";
}else{
document.getElementById("errorforbirth").innerHTML = "出生日期输入不正确";
document.getElementById("birthday").focus();
return false;
}
return true;
}
function clearError(element){
document.getElementById(element).innerHTML = "";
}
</script>
</head>
<body>
<noscript>
提示:您的浏览器不支持或禁止了网页脚本,无法正常注册
</noscript>
<form id="myform" οnsubmit="return validateform()" action="validate.jsp" method="post">
E_mail: <input type="text" name="" id="Emailname" οnkeydοwn="clearError('errorforEmailname')" οnblur="validateform()"/>
<span style="color:red" id="errorforEmailname"></span>
<br/>
Birthday: <input type="text" name="" id="birthday" οnkeydοwn="clearError('errorforbirth')" οnblur="validateform()"/>(日期格式:1990-04-10)
<span style="color:red" id="errorforbirth"></span>
<br/>
<input type="submit" value="保存"/>
</form>
</body>
</html>