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