[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now



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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

649 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