Learn how to a build a cloud-first strategyRegister Now

x
Solved

# javascript

Posted on 2011-03-18
Medium Priority
272 Views
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
Question by:JCWEBHOST
• 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?
0

LVL 39

Assisted Solution

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;
}

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

LVL 40

Expert Comment

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

LVL 40

Expert Comment

ID: 35164377
0

LVL 83

Assisted Solution

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

## Featured Post

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
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…
###### Suggested Courses
Course of the Month21 days, 2 hours left to enroll