Solved

RegularExpressionvalidator Validor for a numeric entry in a textbox

Posted on 2007-12-04
2
1,355 Views
Last Modified: 2013-11-06
I have a textbox for which I allow only integers. How can I define a regularexpressionvalidator for this requirement.

Please help.
Thanks in advance.
0
Comment
Question by:VD1234
2 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 20405119
try this  and attach the function to the textfield

function restrictChars(e) {

        var intKey;

        var restrictedKeys = new Array();

        

        //Set your restricted keyCodes from the URL I gave you

        restrictedKeys[0] = 8

        restrictedKeys[1] = 20
 

        if(window.Event)

            intKey = e.which;

        else

            intKey = e.KeyCode;
 

        for(var i = 0; i < restrictedKeys.length; i++) {

            if(intKey == restrictedKeys[i])

                e.returnValue = false;

            else {

                // Here is a sample check for numerics

                if(intKey > 47 && intKey < 58) {

                    // They pressed a number;

                    e.returnValue = false;

                }

            }

        }

    }

Open in new window

0
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 500 total points
ID: 20405263
use
ValidationExpression="\d+"
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now