[英]How to redirect page based on user input?
使用 JavaScript,我正在尝试根据来自文本框的用户输入设置页面重定向。 当我填写文本框时,每个if
条件都满足,但页面没有重定向。
<script type="text/javascript">
function validateTextBox() {
var box = document.getElementById("width")
var box2 = document.getElementById("height")
var box3 = document.getElementById("length")
if (box.value < 25 && box2.value < 25 && box3.value < 25) {
window.location.href = "jointext.html";
}
}
</script>
</head>
<body>
<form id="theform" action="" method="post" onsubmit="validateTextBox()">
<h3> What do I need </h3>
<div class="row">
<label for ="width"> Width Of Room in Metres </label> <br>
<input type="text" id="width" name=""> <br><br>
</div>
我不知道为什么我在正确的路线上?
我在学习方面相当新,所以任何建议都会很棒。 这是通往 go 的方式吗?如果是这样,我做错了什么。 谢谢大家
尝试使用“onsubmit”而不是“onSubmit”。
新答案尝试使用 action="URL" 而不是 action="" 进行重定向。 如果您希望在 function 中使用它,请调用 remove action=""。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.