File tree 2 files changed +14
-6
lines changed
app/code/Magento/Customer/Block/Widget
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -208,8 +208,16 @@ public function getHtmlId()
208
208
*/
209
209
public function getHtmlExtraParams ()
210
210
{
211
+ $ validators = [];
212
+ $ validators ['required ' ] = true ;
213
+ $ validators ['validate-date ' ] = [
214
+ 'dateFormat ' => $ this ->getDateFormat ()
215
+ ];
216
+
217
+ return 'data-validate=" ' . $ this ->_escaper ->escapeHtml (json_encode ($ validators )) . '" ' ;
218
+
211
219
$ extraParams = [
212
- "'validate-date-au ':true "
220
+ "'validate-date':true " ,
213
221
];
214
222
215
223
if ($ this ->isRequired ()) {
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
976
] ,
977
977
'validate-date-range' : [
978
978
function ( v , elm ) {
You can’t perform that action at this time.
0 commit comments