Solved

RegularExpressionvalidator Validor for a numeric entry in a textbox

Posted on 2007-12-04
2
1,359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...))The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all current…
Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
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…

734 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