Validation of javascript fields

Asked

Viewed 69 times

0

I have a little problem that is:

In certain form fields, the user cannot type letters, special characters (except ., + and -). When the user presses the button . once it does not allow typing the point again. If it type the point again the numbers that appear after the point must be selected.

It’s possible to make this friends?

  • You can get inspired by this question/answer here! Just take the event keypressand do the correct validation to prevent the user from entering the character. For something more cimplexo Voce can look for a plugin

1 answer

0


Yes, there are many components on the web for this. I use the Masked Input Plugin for jQuery, but there are many others like the jQuery Mask Plugin. Place jQuery Mask on Google that you find several. If you do not use jQuery, there are also components that do not need it, but I strongly recommend that you use it.

  • As for input, I was able to fix this. Now the problem is regarding selecting text after . if the user presses the dot again

  • if you do this programmatically, without using component, you will have to deal with all these problems that the component developer has already solved for you. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.