<html>
<head>
<meta charset="UTF-8">
<title>Login</title>
</head>
<body>
<form name="login"> <input type="text" placeholder="user name" name="userid"><br> <input type="password" placeholder="password" name="pswrd"><br><br> <input type="button" onclick "check(this.form)" value="Login" /> </form>
<script>
function check(form) {
if (form.userid.value == "name" && form.pswrd.value == "password") {
window.open('https://www.youtube.com')
} else {
alert("wrong")
}
}
</script>
</body>
</html>
它不起作用......每次我尝试它都不会读取代码。
答案 0 :(得分:1)
您在=
onclick
运算符
<input type = "button" onclick "check(this.form)" value ="Login"/>
^