Reputation: 897
I am using jquery validator plugin when i type us code on my page i need to generate hyphen automatically after 3 digit, the jquery code that I am currently using is and it allow only when use enter mobile number in this format(000-000-0000)
customphone: function(value, element) {
return this.optional(element) || /^\d{3}-\d{3}-\d{4}$/.test(value);
},
But the problem is i manually type the hyphen but and i want to generate that hyphen automatically....Could anyone please help me..
Upvotes: 0
Views: 328
Reputation: 40639
You can try input mask plugin
Just you need to use,
<input data-inputmask="'mask': '999-999-999'">
Upvotes: 1