如何添加手机号验证 HTML程式码:<input type="text" id="mob" name="mob[]" placeholder="Enter mobile no" required>
js代码
container.appendChild(document.createTextNode("mobile"));
var input_m = document.createElement("input");
input_m.type = "text";
input_m.id= id+'_mobile';
input_m.name= "mob[]";
container.appendChild(input_m);
好吧,您可以通过正则表达式执行此操作:
function phonenumber(inputtxt) {
var phoneno = /^\d{10}$/;
if((inputtxt.value.match(phoneno)) {
return true;
} else {
alert("message");
return false;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句