【发布时间】:2020-12-01 19:03:06
【问题描述】:
我的html是:
<input class="UserInfo" type="text" placeholder="phone Format" id="Phone_num">
这是我的 js:
function checkPhoneFormat(){
const phone = document.getElementById("Phone_num").value;
const phoneFormatRex = /^\+?[0-9(),.-]+$/;
var match = phoneFormatRex.exec(phone);
if (match) {
document.getElementById("Phone_num").value = phone;
}
else {
document.getElementById("Phone_num").value = "";
}
}
我想要的是在用户点击输入字段外后检查手机的格式?
【问题讨论】:
标签: javascript html