I use jquery.mask.js for entering client's phone in proper way while registration step.
Plugin does not allow to enter "prohibited" symbols and to enter more symbols than defined by mask:
jQuery("#phone").mask('+38 (ZYY) YYY-YYYY ', {'translation': {
Z: {pattern: /[0-0]/},
Y: {pattern: /[0-9]/}
}
So most users enter correct phone numbers with this mask.
But there is the only one disadvantage with this approach: user can enter less digits than it requires.
In my case, the phone number must consist of 10 digits plus "+38" country prefix.
How can I set PHONE field validation by its length?