User Id :    Password :      New Member   Forgot Password  
 
Validate integer value in java script
Description This is simple codesnippet to chech interger value is valid or not   No. of Views     1102
  Rating     0
Author Najmul Hoda   Posted On     23 Aug 2011
Tags Java Script    

Sample Code   Download Code

 

       Codesnippet to check if a value is integer or not.

 


function Check()
{
    if(isInteger('123'))
        alert('Integer value')

    if(isInteger('123A'))
        alert('Not an integer value')
}



function isInteger(s) {
    var i;
    for (i = 0; i < s.length; i++) {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

 

 

About Author

About Author He is a team lead, having 8+ years of experience. He loves writing technical article for .Net developers. Najmul Hoda
No Photo
 
Country United States
Company BirlaSoft
Home Page http://www.magixchat.com

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

   
Write your comment here.
Comment
Verification Code