Avatar of maqskywalker
maqskywalker
 asked on

using a regular expression to only allow users to type in numbers in a html textbox.

Hi experts,

I created this JavaScript example:

https://jsfiddle.net/wm0peLb6

This example works fine, but this example uses key codes. The textbox only allows a user to type in numbers in the textbox.

I'm trying to created this same example but instead of using keycodes i want to use a Regular Expression to only allow numbers to be typed in.

Anyone know how I revise this example to use a regular expression?
Regular ExpressionsHTMLJavaScript

Avatar of undefined
Last Comment
maqskywalker

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
David H.H.Lee

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
maqskywalker

ASKER
thanks guys.
Your help has saved me hundreds of hours of internet surfing.
fblack61