所以我有这个html:
<form action="insert.php" method="post" onsubmit="return validateForm(this)">
<label for="FUP start date">FUP start date:</label>
<input type="text" name="inputField" id="inputField"/>
</br>
</br>
<label for="FUP end date">FUP end date: </label>
<input type="text" name="inputField2" id="inputField2" />
</br>
</br>
<label for="Allowed traffic">Allowed traffic:</label>
<input type="text" name="Allowed_traffic" id="Allowed_traffic"/>
</br>
</br>
<label for="Frequency">Frequency: </label>
<input type="text" name="Frequency" id="Frequency" />
</br>
</br>
<input type="submit" value="submit">
</form>
而这个用于密码的javascript(Parola):
<script>
function validateForm(formElement) {
if (formElement.Allowed_traffic.length < 5) {
alert('aaaPlease enter a password that is at least 5 characters long');
return false;
}
if (formElement.Allowed_traffic.length > 10) {
alert('Please enter a password that is less than 10 characters long');
return false;
}
}
</script>
我究竟做错了什么?我想在提交时检查密码是否包含 5 到 10 个字符。谢谢!