Solved

javascript

Posted on 2011-03-18
5
260 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
  • 3
5 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 167 total points
Comment Utility
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
Comment Utility
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
Comment Utility
function isNumeric(string)
{
   if ( parseInt(string) != null && parseInt(string) != undefined )
  {
     return true;
   }
     return false;
}
0
 
LVL 40

Expert Comment

by:gurvinder372
Comment Utility
0
 
LVL 82

Assisted Solution

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

Open in new window

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now