javascript - jquery masked input have only first number optional rest mandatory -
im using jquery masked input plugin , need have phone field following format:
1 (222) - 000 - 1114
my code looks this:
$("#myphone").mask("9 (999) - 999 - 9999");
now cant seem work make first digit optional rest mandatory. following numbers valid:
1 (222) - 000 - 1114 (222) - 000 - 1114
and following numbers invalid
1 (222) - 000 - 11 (222) - 00 - 0011
using "?9 (999) - 999- 9999" not work since makes whole thing optional
if cant done in masked can me out regular expression achieve this?
try this:
$.mask.definitions['~'] = '([0-9] )?'; $("#myphone").mask("~(999) - 999 - 9999");
Comments
Post a Comment