我在网页中使用的是电话号码字段。我需要检查在该字段中输入的值是否应为数字和10位数字。为此,我使用了以下代码。
var phonead;
function checkphonead(int){
var filter=/^[0-9]{10}$/;
if (filter.test(int)) {
phonead = true;
}
else {
phonead = false;
}
return phonead;
}
if(document.admission_form.phone.value=='') {
alert("Please enter your phone number");
document.getElementById('phone').focus();
return false;
}
if(checkphonead(document.getElementById('phone').value) == false) {
alert("Please enter a 10 digit phone number!");
document.getElementById('phone').focus();
return false;
}
如果我提交带有任何电话号码的表单,它只会在数据库中保存为2147483647
。如果我删除上述脚本,则正确的电话号码值已保存在数据库中。我无法追查它为什么会发生。有什么建议吗?
答案 0 :(得分:-1)
int是关键词,尝试传递不同的参数名称并尝试!
更新
问题不是javascript ...但是在数据库结构声明中...对于DB中的电话号码结构,请使用bigint,如果在mysql中将其作为文本字段本身保留。它应该工作正常!!