Does anybody know how to solve this problem:

i'm trying to add custom field validation. Chrome console does not have any errors.


    function ($) {
        $.validator.addMethod('test-req', function(v) {
            return false;
        }, 'The amount you entered is too low.');


<input class='required test-req' type='text'  data-bind="value: checker" placeholder='Enter the value' minlength='10' maxlength='10'/>

On page loading fire1 always works. But fire2 is never called. What could be a problem here?


take a look at how Magento 2 validations were added in: lib/web/prototype/validation.js That should give you some hints how to add custom validations.

Also take a look here https://magento.stackexchange.com/a/192407/50597

| improve this answer | |
  • The problem is that i did like manual says and it does not work for me. Normally when you press submit button src/lib/web/mage/validation.js:_create function is called. But in my case does not. – Anthony Feb 5 '18 at 9:59
  • So, did you fixe the issue yet? If so, please share your fix. Otherwise, go ahead with more queries :). – Asrar Feb 5 '18 at 11:00
  • i found that even standard validation is not working. Do you know is there some widget for form initialisation? – Anthony Feb 5 '18 at 11:27

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.