jQuery.isNumeric()
원문 링크
http://api.jquery.com/jQuery.isNumeric/
개요 : 인자가 숫자인지 판별합니다.
- jQuery.isNumeric( value )
- value 숫자인지 확인할 인자
$.isNumeric() 함수는 인자가 숫자 값인지 확인합니다. 숫자라면 true. 아니라면 false를 반환합니다. 인자는 뭐든지 사용가능합니다.
예 제
다양한 값들을 체크해 봅니다.
$.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
이거이거 정말 유용합니다. isNaN()으로 고생하는 분들 많죠. 16진수까지도 체크해 주네요. 완소 함수입니다.
그럼 즐프하세요.
※ 본 예제는 http://www.jquery.com 에 있는 내용임을 밝힙니다.
'프로그래밍 > jQuery' 카테고리의 다른 글
| jQuery.makeArray(), 자바스크립트 배열로 변환 (0) | 2012.07.02 |
|---|---|
| jQuery.isXMLDoc(), XML 문서인지 확인 (0) | 2012.07.02 |
| jQuery.isWindow(), Window 인지 확인 (0) | 2012.07.02 |
| jQuery.isPlainObject(), object인지 확인 (0) | 2012.07.02 |
| jQuery.isFunction(), JavaScript 함수인지 확인 (2) | 2012.07.02 |
| jQuery.isEmptyObject(), 객체가 empty 인지 확인 (0) | 2012.07.02 |
| jQuery.isArray(), 배열인지 확인 (0) | 2012.07.02 |
| jQuery.inArray(), 배열 내의 값을 찾아서 인덱스를 반환 (0) | 2012.07.02 |