RegularExpressionvalidator Validor for a numeric entry in a textbox

I have a textbox for which I allow only integers. How can I define a regularexpressionvalidator for this requirement.

Please help.
Thanks in advance.
VD1234Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Sinoj SebastianConnect With a Mentor CTO & OpenERP Project managerCommented:
use
ValidationExpression="\d+"
0
 
erikTsomikSystem Architect, CF programmer Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.