My html is:
<input class="UserInfo" type="text" placeholder="phone Format" id="Phone_num">
Here is my 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 = "";
}
}
what i want is to check the format of the phone after the user click outside the input field?