I have this input and i want to add validation for date

  <input class="input-text validate-date" data-validate="{required:true}"
    value: value,
    valueUpdate: 'keyup',
    hasFocus: focused,
    attr: {
        name: inputName,
        placeholder: placeholder,
        'aria-describedby': noticeId,
        id: uid,
        disabled: disabled
    }" name="custom_attributes[amorderattr_birth__date]" placeholder="" aria-describedby="notice-N780KER" id="N780KER" style="

I already added this class class="input-text validate-date" data-validate="{required:true}"> but nothing happen.

Does anyone have any idea how it's the proper way to add date validation for this filed?

1 Answer 1


put this code into your phtml

  ], function($){
        $(document).ready(function () {
            var dataForm = $('#<form_id>');                 
            var ignore = null;

            dataForm.mage('validation', {
                    ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
                }).find('input:text').attr('autocomplete', 'off');
            if (dataForm.validation('isValid') == false) {
                return false;
  • where in this script can i specify my input? Mar 9, 2017 at 14:31
  • add data-mage-init='{"validation":{}}' in form element Mar 11, 2017 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.