jQuery jQuery.isNumeric() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Number test

What You’ll Learn

The jQuery.isNumeric() utility returns true when a value is a finite number or a string that parses as one. This tutorial covers syntax, five worked examples from the official API, comparisons with isNaN(), form validation patterns, and values that fail the test.

01

Syntax

$.isNumeric(val)

02

Boolean

true / false

03

Number

10 yes

04

String

"10" yes

05

Finite

No NaN/∞

06

Forms

Input check

Introduction

Form fields, plugin options, and AJAX payloads often arrive as strings — even when they represent numbers. Before you call parseInt, do math, or pass a value to a jQuery animation duration, you need to know whether the input is actually numeric.

jQuery provides jQuery.isNumeric() (also written $.isNumeric()) as a single boolean test. It accepts numbers and numeric strings, rejects empty strings, booleans, NaN, Infinity, and values like "10px" that only partially parse as numbers.

Understanding the jQuery.isNumeric() Method

jQuery.isNumeric(value) returns true only when value is a number or string whose entire content represents a finite numeric value. Internally jQuery checks the type, parses when needed, and verifies the result is not NaN or infinite.

Use it in validation helpers, slider widgets, quantity inputs, and anywhere user text must be confirmed as a plain number before calculation — not as a replacement for range checks or business rules.

💡
Beginner Tip

typeof x === "number" is true for NaN and Infinity. $.isNumeric(NaN) is false — that is why this utility exists.

📝 Syntax

General form of jQuery.isNumeric:

jQuery
jQuery.isNumeric( value )
// or
$.isNumeric( value )

Parameters

  • value — any JavaScript value to test.

Return value

  • true if value is a finite number or numeric string.
  • false for all other types and non-numeric strings.

Minimal workflow

jQuery
var raw = $("#quantity").val();
if ($.isNumeric(raw)) {
  var qty = parseFloat(raw);
}

⚡ Quick Reference

Value$.isNumeric()
10 / "10"true
-10 / "-3.5"true
0true
""false
true / {}false
NaN / Infinityfalse
"10px"false

📋 $.isNumeric vs isNaN vs typeof

Three ways to inspect numbers — different strictness and coercion rules.

$.isNumeric
finite only

Number or numeric string; jQuery strict

isNaN
coerces

Surprises like isNaN("") === false

typeof
"number"

Includes NaN and Infinity

Number.isFinite
ES2015

Native finite number check

Examples Gallery

Each example uses $.isNumeric(). Open DevTools or use the Try-it links to run them interactively.

📚 Getting Started

Official jQuery API examples — numbers and numeric strings pass.

Example 1 — Numbers and Numeric Strings

The canonical passing cases from the jQuery documentation.

jQuery
console.log($.isNumeric(10));    // true
console.log($.isNumeric("10"));  // true
console.log($.isNumeric("-10")); // true
console.log($.isNumeric(0));     // true
Try It Yourself

How It Works

Both native numbers and their string equivalents pass. Zero is numeric — do not confuse emptiness ("") with zero (0).

📈 Practical Patterns

Rejections, decimals, form validation, and comparison with isNaN.

Example 2 — Values That Fail the Test

From the official docs — common non-numeric inputs.

jQuery
console.log($.isNumeric(""));        // false
console.log($.isNumeric(true));      // false
console.log($.isNumeric(NaN));       // false
console.log($.isNumeric(Infinity));  // false
console.log($.isNumeric("10px"));    // false
Try It Yourself

How It Works

Empty strings, booleans, non-finite numbers, and strings with trailing units all fail. parseFloat("10px") returns 10, but isNumeric correctly rejects the full string.

Example 3 — Negative Numbers and Decimals

Floating-point values and their string forms are accepted.

jQuery
console.log($.isNumeric(-3.14));    // true
console.log($.isNumeric("-3.14"));  // true
console.log($.isNumeric("0.5"));     // true
Try It Yourself

How It Works

Integers and decimals behave the same whether stored as numbers or read from text inputs. After validation, use parseFloat for math.

Example 4 — Validate a Form Field Before Submit

Guard quantity input — show an error when the value is not numeric.

jQuery
function validateQuantity(val) {
  if (!$.isNumeric(val)) {
    return "Enter a valid number";
  }
  var n = parseFloat(val);
  if (n < 1) {
    return "Minimum quantity is 1";
  }
  return "OK: " + n;
}

console.log(validateQuantity("5"));   // OK: 5
console.log(validateQuantity("abc")); // Enter a valid number
Try It Yourself

How It Works

isNumeric answers “is it a number at all?” Separate checks handle minimum, maximum, and integer-only rules after the value passes.

Example 5 — Why Not isNaN Alone?

isNaN coerces types — $.isNumeric is stricter for input validation.

jQuery
console.log(isNaN(""));           // false — "" coerces to 0!
console.log($.isNumeric(""));     // false — correct for empty input

console.log(typeof NaN);           // "number"
console.log($.isNumeric(NaN));     // false
Try It Yourself

How It Works

For user-facing validation, prefer $.isNumeric over bare isNaN. In modern jQuery-free code, combine trimmed string checks with Number.isFinite(Number(s)) for similar strictness.

🚀 Common Use Cases

  • Form validation — quantity, age, price, and rating fields.
  • Plugin options — confirm duration, opacity, or index values are numeric.
  • Animation helpers — validate speed/delay before passing to .animate().
  • CSV / paste parsing — filter rows where a column should be numeric.
  • AJAX payloads — guard string fields that must parse as numbers.
  • Legacy jQuery UI — consistent numeric checks across older widgets.

🧠 How jQuery.isNumeric() Validates a Value

1

Check type

Only number and string types can proceed — others return false.

Type
2

Parse value

jQuery parses the string or number and compares parsing consistency.

Parse
3

Require finite

Reject NaN, Infinity, and strings that are not fully numeric.

Finite
4

Return boolean

true only for valid finite numeric values.

📝 Notes

  • Available since jQuery 1.7.
  • Accepts negative numbers and decimal strings.
  • Rejects hex strings like "0xFF" and strings with units like "10px".
  • Does not validate integer-only — use extra checks after isNumeric.
  • Whitespace-only strings typically fail — trim input first if needed.
  • Related: $.type() returns "number" for NaN — pair with isNumeric for input validation.

Browser Support

jQuery.isNumeric() has been part of jQuery since jQuery 1.7+. It works wherever jQuery runs — all modern browsers and legacy IE when paired with a supported jQuery build.

jQuery 1.7+

jQuery jQuery.isNumeric()

Supported in jQuery 1.x, 2.x, and 3.x. Behavior is consistent across browsers because jQuery owns the validation logic.

100% With jQuery loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
jQuery.isNumeric() Universal

Bottom line: Safe in any project that already includes jQuery. Without jQuery, validate with Number.isFinite(Number(trimmed)) on string inputs.

Conclusion

The jQuery.isNumeric() utility is the jQuery way to confirm a value is a finite number or numeric string. It rejects the traps that typeof and isNaN leave open — empty strings, NaN, Infinity, and partial parses like "10px".

Use it before parseFloat on user input, then apply your own range and format rules — and explore jQuery.isPlainObject() when validating settings objects for $.extend().

💡 Best Practices

✅ Do

  • Use $.isNumeric before parsing form strings
  • Trim input when users may add spaces
  • Follow with min/max and integer checks as needed
  • Reject CSS values with units separately
  • Prefer Number.isFinite in jQuery-free code

❌ Don’t

  • Rely on isNaN(val) alone for empty strings
  • Assume typeof x === "number" excludes NaN
  • Use parseFloat success as full validation
  • Expect hex or currency strings to pass
  • Skip range validation after isNumeric passes

Key Takeaways

Knowledge Unlocked

Five things to remember about jQuery.isNumeric()

Validate numbers the jQuery way.

5
Core concepts
02

"10" OK

String nums

Pass
🚫 03

NaN no

Not finite

Fail
🚫 04

10px no

Not pure

Units
📝 05

Forms

Validate

Use

❓ Frequently Asked Questions

jQuery.isNumeric(value) returns true when value is a finite number or a string that represents a finite number (such as "10" or "-3.5"). It returns false for empty strings, booleans, NaN, Infinity, and strings with extra characters like "10px".
Yes. Both 42 and "42" return true. The string must parse entirely as a number — partial matches like "12abc" or CSS values like "10px" return false.
isNaN coerces values and can produce surprising results — isNaN("") is false because "" coerces to 0. $.isNumeric("") is false. Use $.isNumeric for stricter finite-number checks in jQuery code.
Yes. -10, "-10", 3.14, and "3.14" all return true when they represent finite numbers.
Only finite numeric values pass. Infinity and NaN are typeof "number" in JavaScript but are not useful as ordinary numeric input — jQuery excludes them intentionally.
Validate text inputs before parseInt, parseFloat, or math — e.g. if ($.isNumeric($("#age").val())) { ... }. Pair with range checks after confirming the value is numeric.
Did you know?

jQuery added isNumeric in version 1.7 because plugin authors kept reimplementing the same parse-and-validate snippet. The official demo fits on one line — $.isNumeric("-10") — but the real value is rejecting "" and "10px", cases where raw parseFloat misleads beginners.

Continue to jQuery.isPlainObject()

Test plain {} objects before merging with jQuery.extend().

isPlainObject() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful