<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form>
Name:<input type="text" id="t1"> <br> Gender: <input
type="radio" name="sex" value="male">male <input type="radio"
name="sex" value="female">female <br> <input
type="submit" value="submit" onClick="myFunction()">
</form>
<script type="text/javascript">
function myFunction() {
var str = document.getElementById("t1").value;
if (str == "") {
alert("plz enter anything");
}
}
</script>
</body>
</html>
我想验证什么时候没有用户输入,如果用户按下提交按钮,那么它应该提醒“输入任何东西”但它不起作用.......为什么我不知道