php中实现为空时提示代码 php正则表达式

2012 年 12 月 10 日5080

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://http://www.zjjv.com///TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://http://www.zjjv.com///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head> <body>
<form method="post" action="add.php" onsubmit="return chkreg(form1,'all')">
<p>学号:
<input type="text" onBlur="chkreg(form1,0)"/>
<span></span></p> <p>姓名:
<input type="text" onBlur="chkreg(form1,1)"/>
<span></span></p>
<p>
<label>
<input type="submit" value="提交" />
</label>
</p> <script language="javascript">
function chkreg(form,label){
if(label==0 || label=="all"){
if(form.xh.value==""){
check_recuser.innerHTML="*请输入学号!";
form.xh.style.backgroundColor="#F1B000";
return false;
}else{
check_recuser.innerHTML="";
form.xh.style.backgroundColor="#FFFFFF";
}
}
if(label==1 || label=="all"){
if(form.xm.value==""){
check_recuser1.innerHTML="*请输入姓名!";
form.xm.style.backgroundColor="#F1B000";
return false;
}else{
check_recuser1.innerHTML="";
form.xm.style.backgroundColor="#FFFFFF";
}
} }
</script>
</form>
</body>
</html>

0 0