From c7f318ce01f3ac13c199a366369a5158d7b694da Mon Sep 17 00:00:00 2001 From: Joachim Vanthuyne Date: Tue, 26 Sep 2017 16:03:53 +0200 Subject: [PATCH] Fix dob date validation on custom locale --- app/code/Magento/Customer/Block/Widget/Dob.php | 18 +++++------------- lib/web/mage/validation.js | 1 + 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php index 74b9a9c9af29b..f8ee8fddf2ea2 100644 --- a/app/code/Magento/Customer/Block/Widget/Dob.php +++ b/app/code/Magento/Customer/Block/Widget/Dob.php @@ -209,24 +209,16 @@ public function getHtmlId() public function getHtmlExtraParams() { $validators = []; - $validators['required'] = true; - $validators['validate-date'] = [ - 'dateFormat' => $this->getDateFormat() - ]; - - return 'data-validate="' . $this->_escaper->escapeHtml(json_encode($validators)) . '"'; - - $extraParams = [ - "'validate-date':true", - ]; if ($this->isRequired()) { - $extraParams[] = 'required:true'; + $validators['required'] = true; } - $extraParams = implode(', ', $extraParams); + $validators['validate-date'] = [ + 'dateFormat' => $this->getDateFormat() + ]; - return 'data-validate="{' . $extraParams . '}"'; + return 'data-validate="' . $this->_escaper->escapeHtml(json_encode($validators)) . '"'; } /** diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index f99cdc8886808..85158c581aec1 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -973,6 +973,7 @@ return $.mage.isEmptyNoTrim(value) || test.isValid(); }, $.mage.__('Please enter a valid date.') + ], 'validate-date-range': [ function (v, elm) {