3

Just started with jquery and am trying to get form validation to work using the validation plugin. Then I discovered the maskedinput plugin (http://digitalbush.com/projects/masked-input-plugin/) and tried to use it on a phone number field.

Things work to a point: When the phone field comes in focus it displays the place holders and allows you to enter a phone number and limits you to digits - very nice!

However, if you only enter 9 digits instead of the required 10 (assuming US phone number), yes, unlikely, but crazier stuff has and will happen, and you click submit, then anything that was already in the phone field is cleared. If you enter the entire phone number and validation fails on some other field the entry in the phone field sticks.

How can I prevent this?

Thanks hgg

  • Hi, here is an example of the validation plugin and masked input working together, it might help you out http://jquery.bassistance.de/validate/demo/marketo/step2.htm – Alex KeySmith Aug 01 '11 at 11:33
  • Alex, that example shows it NOT working together. The difference is that the example you provided doesn't style .valid on form elements. - click into the credit card number input - type 3 numbers - click out - the field is now marked as "valid" when it shouldn't be. – James Feb 27 '12 at 02:08
  • Did you ever find a solution to this problem? I am having the same trouble. – Amanda Kitson Mar 05 '12 at 02:52

1 Answers1

0

if you use the masked input plugin
it works in that way it allow all the values or none
so better not use masked input if you want 9 / 10 values , bcoz masked input can have limited number of values as much defined
not less not more than that

Vijay Parmar
  • 795
  • 4
  • 13