我正在尝试使用javascript验证文本字段。return false运行得很好。但是return true不起作用。
HTML
<form namme="frms" action="booking_management.php">
<input type="text" name="total" id="totald" value="" onkeyup="calbill()" class="input"/>
<input name="but" type="button" value="Send Bill" class="btn btn-primary" onClick="bill()" />
</form>JavaScript
function bill() {
if (Checktot()) {
document.forms["frms"].submit();
}
}
function Checktot() {
var tot = document.getElementById("totald").value;
if (tot == "no") {
document.getElementById("totald").style.borderColor = "#ED291F";
alert("Please try again");
return false;
}
return true;
}发布于 2015-03-05 13:37:57
您收到错误:
未捕获的提交:无法读取未定义的“”submit“”属性
document.forms["frms"].submit();ERROR DEMO
您可以使用以下命令:
document.forms[0].submit()https://stackoverflow.com/questions/28870606
复制相似问题