JS非空验证


代码如下:

<!DOCTYPE html>
<html>
	<meta charset="UTF-8">
		<title></title>
	<head>
		<script language="javascript">
			function checklogin() {
				if((myform.user.value != "")) {
					if((myform.pwd.value != "")) {
						return true
					} else {
						alert("密码不能为空");
						return false
					}
				} else {
					alert("用户名不能为空");
					return false
				}
			}
		</script>
		<title></title>
	</head>

	<body>
		<form action="form.html" name="myform" method="post" onSubmit="return checklogin()">

			<input type="text" name="user" size="16"><br>
			<input type="password" name="pwd" size="16"><input type="submit" value="登录" name="sub_1">
		</form>

	</body>

</html>

  

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM