I have met an issue with validation phone field that could be different length. Being not very experienced with validations i have found may be not best solution but for my situation it worked you.
May be it will help you.
So problem is that for one country mask length - 10, for another 12, for another 13 and we need to warn user to fill phone field completly.
I used this algorithm:
Change inputmask initialization setting 'autoUnmask': false, so when getting input value - you get it with _ symbol
Use this simpliest regexp to find if there any '_' left in input field , if so - field not completed
if (/_/.test(phoneInput.val())) {
alert('phone empy, pls enter phone');
//do any stuff u want here - shows divs erros etc
}
Little advantage over //clearIncomplete: true, is that it leaves user input to complete later
Would be glad to know correct/other ways to validate different length
I have met an issue with validation phone field that could be different length. Being not very experienced with validations i have found may be not best solution but for my situation it worked you. May be it will help you.
So problem is that for one country mask length - 10, for another 12, for another 13 and we need to warn user to fill phone field completly. I used this algorithm:
if (/_/.test(phoneInput.val())) { alert('phone empy, pls enter phone'); //do any stuff u want here - shows divs erros etc }
Little advantage over //clearIncomplete: true, is that it leaves user input to complete later
Would be glad to know correct/other ways to validate different length