Posted on 2011-03-18
Medium Priority
Last Modified: 2012-05-11
hey guys, i need a javascript to for validating integer number in a textbox or the pattern for rex editor?

here is one for decimal

function DecimalValidator(source, args)
    var Value = document.getElementById(source.controltovalidate).value;  
    var pattern = /^\d+(\.\d{1,2})?$/  
     if (!pattern.test(Value))  
            args.IsValid =false;
            document.getElementById(source.controltovalidate).className=  "errorbox";
            args.IsValid = true;
Question by:JCWEBHOST
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
  • 3
LVL 40

Accepted Solution

Gurvinder Pal Singh earned 668 total points
ID: 35164296
how many digits before the decimal and how many after the decimal is required?
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 664 total points
ID: 35164320
Now you want only for Integer no decimals

function IsNumeric(strString)
   //  check for valid numeric strings      
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         blnResult = false;
   return blnResult;

LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 35164375
function isNumeric(string)
   if ( parseInt(string) != null && parseInt(string) != undefined )
     return true;
     return false;
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 35164377
LVL 82

Assisted Solution

leakim971 earned 668 total points
ID: 35165681
var pattern = /\D/
if (pattern.test(Value)) 

Open in new window


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

752 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