Thursday, September 1, 2011

Check the number for integer in JavaScript

If you want to check the number to be integer, you can use this function:

isInt = function(field) {
  if (+field != field || field.indexOf(".") != -1) {
    return false;
  } else {
    return true;
  }
}

0 comments:

Post a Comment