对于我的 html,我正在尝试使用邮政编码输入验证表单。
但是此输入不起作用(或未被识别)。对于我的邮政编码输入,我希望文本框仅接受数字。
邮政编码输入:
var Postcode = document.forms["Rego"]["postcode"].value;
var e = Postcode;
var code = e.keyCode;
if (code > 47 && code < 58) || code == 40 || code == 41 || code == 43) {
return true;
}
alert("Invalid Postcode. Please enter numbers only.");
return false;
我做错了什么?
最佳答案
在你的情况下,如果在第 4 行 58 之后,为什么你关闭 ) ???
关于javascript - 尝试验证 HTML 中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23453211/