Skip to main content

Bug Tracker

Side navigation

#10690 closed bug (fixed)

Opened November 05, 2011 11:40PM UTC

Closed November 07, 2011 04:26PM UTC

Last modified March 08, 2012 08:16PM UTC


Reported by: Owned by: dmethvin
Priority: blocker Milestone: 1.7.1
Component: core Version: 1.7
Keywords: Cc:
Blocked by: Blocking:

The isNumeric function use does not give the right result in every case. If the "number" is a date object it returns true, but a date is not a number.

the right functio should be

isNumeric: function( obj ) {
return !isNaN(parseFloat(obj)) && isFinite(obj);

Here's a site (not mine) that proves it:

But 'cause it's not my site I copy pasted the site and add the jQuery function


Attachments (0)
Change History (5)

Changed November 05, 2011 11:49PM UTC by rwaldron comment:1

component: unfiledcore
owner: →
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate:

Open the link and click to "Fork" (in the top menu) to get started.

Changed November 06, 2011 12:28AM UTC by comment:2

status: pendingnew

The problem still exist in the jQuery Edge.

Here is a test case that shows only the date problem

and here is a test case that is more detailed

Changed November 06, 2011 03:36AM UTC by rwaldron comment:3

On the "more detailed" test, I'm getting all passing tests, is that correct?

Changed November 06, 2011 02:09PM UTC by dmethvin comment:4

milestone: None1.7.1
owner: shiroiyamii@gmail.comdmethvin
priority: undecidedblocker
status: newassigned

I'd agree that a Date object isn't logically numeric, although +(new Date) does yield a perfectly usable number and that is essentially what is being measured.

The general case where an object has a .toString() still works for both approaches, and I think we *do* want that. As long as the proposed new code doesn't break that I'm okay with it.

Changed November 07, 2011 04:26PM UTC by Dave Methvin comment:5

resolution: → fixed
status: assignedclosed

Fix #10690. Make sure .isNumeric() can't get a Date.

Also add tests for custom objects with a .toString() method.

Changeset: 795583d2936a48c6f0048e28f74c5fc71e3a60b0