File tree 2 files changed +11
-13
lines changed
app/code/Magento/Customer/Block/Widget
2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -208,17 +208,14 @@ public function getHtmlId()
208
208
*/
209
209
public function getHtmlExtraParams ()
210
210
{
211
- $ extraParams = [
212
- "'validate-date-au':true "
213
- ];
214
-
211
+ $ validators = [];
215
212
if ($ this ->isRequired ()) {
216
- $ extraParams [ ] = ' required: true' ;
213
+ $ validators [ ' required ' ] = true ;
217
214
}
218
-
219
- $ extraParams = implode ( ' , ' , $ extraParams );
220
-
221
- return 'data-validate="{ ' . $ extraParams . '} " ' ;
215
+ $ validators [ ' validate-date ' ] = [
216
+ ' dateFormat ' => $ this -> getDateFormat ()
217
+ ];
218
+ return 'data-validate=" ' . $ this -> _escaper -> escapeHtml ( json_encode ( $ validators )) . '" ' ;
222
219
}
223
220
224
221
/**
Original file line number Diff line number Diff line change 9
9
if ( typeof define === 'function' && define . amd ) {
10
10
define ( [
11
11
'jquery' ,
12
+ 'moment' ,
12
13
'jquery/ui' ,
13
14
'jquery/validate' ,
14
15
'mage/translate'
15
16
] , factory ) ;
16
17
} else {
17
18
factory ( jQuery ) ;
18
19
}
19
- } ( function ( $ ) {
20
+ } ( function ( $ , moment ) {
20
21
'use strict' ;
21
22
22
23
var creditCartTypes , rules , showLabel , originValidateDelegate ;
966
967
$ . mage . __ ( 'Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.' ) //eslint-disable-line max-len
967
968
] ,
968
969
'validate-date' : [
969
- function ( v ) {
970
- var test = new Date ( v ) ;
970
+ function ( value , params , additionalParams ) {
971
+ var test = moment ( value , additionalParams . dateFormat ) ;
971
972
972
- return $ . mage . isEmptyNoTrim ( v ) || ! isNaN ( test ) ;
973
+ return $ . mage . isEmptyNoTrim ( value ) || test . isValid ( ) ;
973
974
} ,
974
975
$ . mage . __ ( 'Please enter a valid date.' )
975
976
You can’t perform that action at this time.
0 commit comments