I have the following javascript in our forms making all of the phone number fields default to a specific format:
$(document).ready(function () {
$(".Phone").on("change" , "input" , mask_num);
function mask_num(){
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.min.js', function () {
$(".Phone input").mask("(999)999-9999");
});
}
});
This part works great, but many of those using our forms are not entering 10 digits. We tried specifying they enter a 10 digit number, but we still often only get 7 digits. I am trying to make it so they have to enter the 10 digit number but that it still automates the formatting. I have tried entering both \(\d\d\d\) \d\d\d-\d\d\d\d and >=1000000000 & <=9999999999 as field constraints but receive an error when 10 digits are entered but not in the exact format (if they just enter 2083159944 instead of (208)315-9944, even though the javascript does correct the formatting). Any idea how I can keep the javascript formatting and require 10 digits? I imagine I can add something to my script, but I am not familiar enough with javascript to know what I need to add.
Thanks!
Amanda Payne