<html>
<head>
<script language="javascript">
function mycheck(){
if(myform.user.value==""){
window.alert("用户名称不能为空!!");
myform.user.focus();
return false;
}
if(myform.pwd.value==""){
window.alert("用户密码不能为空!!");
myform.pwd.focus();
return false;
}
}
</script>
</head>
<body>
<form action="" method="post" name="myform">
<table width="532" height="183" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCFF66" background="logo.jpg">
<tr>
<td height="71" colspan="2" align="center"> </td>
</tr>
<tr>
<td width="249" height="30" align="center"> </td>
<td width="281" align="left">
用户名:<input name="user" type="text" id="user" size="20"><br><br>
密 码:<input name="pwd" type="password" id="pwd" size="20">
</td>
</tr>
<tr>
<td height="43" align="center"> </td>
<td height="43" align="center">
<input type="submit" name="submit" onClick="return mycheck()" value="登录">
<input type="reset" name="submit2" value="重置">
</td>
</tr>
</table>
</form>
</body>
</html>
应用javascript脚本验证表单元素是否为空
最新推荐文章于 2019-04-15 11:28:02 发布