From d818a4f4ecd7a709140fc817a087531ff4ee34a2 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Thu, 15 Feb 2018 00:55:44 +0000 Subject: [PATCH] Core: Add deprecation warning to 'date' method Ref #1787 --- src/core.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/core.js b/src/core.js index f2d986118..74d195e42 100644 --- a/src/core.js +++ b/src/core.js @@ -1385,9 +1385,26 @@ $.extend( $.validator, { }, // https://jqueryvalidation.org/date-method/ - date: function( value, element ) { - return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() ); - }, + date: ( function() { + var called = false; + + return function( value, element ) { + if ( !called ) { + called = true; + if ( this.settings.debug && window.console ) { + console.warn( + "The `date` method is deprecated and will be removed in version '2.0.0'.\n" + + "Please don't use it, since it relies on the Date constructor, which\n" + + "behaves very differently across browsers and locales. Use `dateISO`\n" + + "instead or one of the locale specific methods in `localizations/`\n" + + "and `additional-methods.js`." + ); + } + } + + return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() ); + }; + }() ), // https://jqueryvalidation.org/dateISO-method/ dateISO: function( value, element ) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy