IT/jquery_javascript

jquery 숫자 여부 체크 isNumeric

당양부부34 2014. 2. 13. 15:42

jQuery.isNumeric( value )Returns : Boolean

개요 : 인자가 숫자인지 판별합니다.

  • jQuery.isNumeric( value )
  • value 숫자인지 확인할 인자

$.isNumeric() 함수는 인자가 숫자 값인지 확인합니다. 숫자라면 true. 아니라면 false를 반환합니다. 인자는 뭐든지 사용가능합니다. 16진수도 체크 가능하네요.

예 제  
다양한 값들을 체크해 봅니다.

$.isNumeric("-10");  // true
$.isNumeric(16);     // true
$.isNumeric(0xFF);   // true
$.isNumeric("0xFF"); // true
$.isNumeric("8e5");  // true (exponential notation string)
$.isNumeric(3.1415); // true
$.isNumeric(+10);    // true
$.isNumeric(0144);   // true (octal integer literal)
$.isNumeric("");     // false
$.isNumeric({});     // false (empty object)
$.isNumeric(NaN);    // false
$.isNumeric(null);   // false
$.isNumeric(true);   // false
$.isNumeric(Infinity); // false
$.isNumeric(undefined); // false