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?


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? – Alin Lupoiu Mar 9 '17 at 14:31
  • add data-mage-init='{"validation":{}}' in form element – Ronak Chauhan Mar 11 '17 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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