Skip to content

Commit

Permalink
Fix dob date validation on custom locale
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimVT committed Sep 26, 2017
1 parent f0baa28 commit c7f318c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
18 changes: 5 additions & 13 deletions app/code/Magento/Customer/Block/Widget/Dob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) . '"';
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/web/mage/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@
return $.mage.isEmptyNoTrim(value) || test.isValid();
},
$.mage.__('Please enter a valid date.')

],
'validate-date-range': [
function (v, elm) {
Expand Down

0 comments on commit c7f318c

Please sign in to comment.