Solved

javascript

Posted on 2011-03-18
5
266 Views
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";
           
        }
        else
        {
            args.IsValid = true;
            document.getElementById(source.controltovalidate).className='correctbox';
        }
}  
0
Comment
Question by:JCWEBHOST
[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
  • 3
5 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 167 total points
ID: 35164296
how many digits before the decimal and how many after the decimal is required?
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 166 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;
   }

refer
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26880094.html
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35164375
function isNumeric(string)
{
   if ( parseInt(string) != null && parseInt(string) != undefined )
  {
     return true;
   }
     return false;
}
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35164377
0
 
LVL 82

Assisted Solution

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

Open in new window

0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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