Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Making sure user enters only numbers
Message
General information
Forum:
Internet
Category:
VBScript
Miscellaneous
Thread ID:
00427000
Message ID:
00437715
Views:
20
>What's the best way to make sure the users only enter numbers in the web page textboxes? My options I think are:
>
>1. Running a jscript to check each field just prior to form submission and prompt the user to enter only numbers.
>2. When posting entered data, call a function to convert all values to numeric.
>
>I have a form with 50 textboxes that should only have numbers when it's posted and unsure from standpoint of accuracy and performance which method is best.

In VBScript the abs() function will strip out all non-numeric data.
Use event-bubbling and in the onClick event in the body tag call a function. In that function get the: window.event.srcElement.id

Then, in a switch statement, if the id is one of your numeric fields, execute a test and alert the user in a cumulative messagebox text field.
Carl R. Perkins
NJ5J Software Corp. http://www.nj5j.com
Previous
Reply
Map
View

Click here to load this message in the networking platform