Solved

RegularExpressionvalidator Validor for a numeric entry in a textbox

Posted on 2007-12-04
2
1,354 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
Comment Utility
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
Comment Utility
use
ValidationExpression="\d+"
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

762 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

11 Experts available now in Live!

Get 1:1 Help Now