Skip to content

Commit d570e1d

Browse files
committed
Merge magento#11067 commit 'refs/pull/11067/head' of https://github.com/magento/magento2 into MAGETWO-80096-PR-11067
# Conflicts: # app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/swagger-ui.js # dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Backend/_files/controller_acl_test_whitelist_ce.txt
2 parents e442de5 + c7f318c commit d570e1d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

app/code/Magento/Customer/Block/Widget/Dob.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ public function getHtmlId()
208208
*/
209209
public function getHtmlExtraParams()
210210
{
211-
$extraParams = [
212-
"'validate-date-au':true"
213-
];
211+
$validators = [];
214212

215213
if ($this->isRequired()) {
216-
$extraParams[] = 'required:true';
214+
$validators['required'] = true;
217215
}
218216

219-
$extraParams = implode(', ', $extraParams);
217+
$validators['validate-date'] = [
218+
'dateFormat' => $this->getDateFormat()
219+
];
220220

221-
return 'data-validate="{' . $extraParams . '}"';
221+
return 'data-validate="' . $this->_escaper->escapeHtml(json_encode($validators)) . '"';
222222
}
223223

224224
/**

lib/web/mage/validation.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
if (typeof define === 'function' && define.amd) {
1010
define([
1111
'jquery',
12+
'moment',
1213
'jquery/ui',
1314
'jquery/validate',
1415
'mage/translate'
1516
], factory);
1617
} else {
1718
factory(jQuery);
1819
}
19-
}(function ($) {
20+
}(function ($, moment) {
2021
'use strict';
2122

2223
var creditCartTypes, rules, showLabel, originValidateDelegate;
@@ -966,10 +967,10 @@
966967
$.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
967968
],
968969
'validate-date': [
969-
function (v) {
970-
var test = new Date(v);
970+
function (value, params, additionalParams) {
971+
var test = moment(value, additionalParams.dateFormat);
971972

972-
return $.mage.isEmptyNoTrim(v) || !isNaN(test);
973+
return $.mage.isEmptyNoTrim(value) || test.isValid();
973974
},
974975
$.mage.__('Please enter a valid date.')
975976

0 commit comments

Comments
 (0)