Hi! I’m really in the mood to add up some stuff in my blog. So here I am again. Expect that there will be more quick tutorials like this since I’ll be working on a project, a website to be exact. I can’t really afford to do some in-depth tutorials so I’ll just do it like this.
Okay, enough with the quick update of my life. This time, I’m going to show you how you can control what kind of input goes to your text fields using jquery.
You can actually view the source of this demo and get your way through it. But if you cannot make it work then you can continue reading.
First, you have to include both the jquery core and jquery numeric plugin in your file:
The code is pretty much self-explanatory. The 2nd line says that any text input element (textfield, textarea) that has an attribute of class which is equal to numeric will be affected by the script which only lets you to input numbers on a text field. The following lines does the same thing but with a different flavor.
That’s it for this quick tutorial. I hope you learned something, thanks for reading!