When I do in checkout, I got an error : I would like to detect if the person has filled in the registration form in the checkout, this code is added in this file : app/design/frontend/Theme/theme/Amasty_CheckoutCore/templates/onepage.phtml

define(['jquery','mage/translate', 'mage/validation'], function($){
    "use strict";
    return {
        customMain: function (){



error :

Uncaught Error: cannot call methods on validation prior to initialization; attempted to call method 'isValid'

  • Magento default support validates the shipping address form. What are you trying to do? Could you describe it in more detail?
    – Tu Van
    Nov 3, 2022 at 11:32
  • @TuVan I would like to add an extra step in full javascript, and then I have to activate or deactivate a button by checking if the form is well filled or not
    – Kevin ami
    Nov 3, 2022 at 11:33
  • Could you add the related xml, JS file, and a screenshot on the checkout page?
    – Tu Van
    Nov 3, 2022 at 11:43
  • @TuVan I updated the code, I added the code in this file : app/design/frontend/Theme/theme/Amasty_CheckoutCore/templates/onepage.phtml
    – Kevin ami
    Nov 3, 2022 at 13:31

2 Answers 2


Place your code inside require and load mage/validation

], function($){
   // Place your other code here


  • this is what I did
    – Kevin ami
    Nov 3, 2022 at 13:02
  • It puts an error in the console
    – Kevin ami
    Nov 3, 2022 at 13:09

You have to run validation() function before use isValid.

Use this code to validate the shipping form:

var shippingForm = $('#co-shipping-form');
if (shippingForm.validation() && shippingForm.validation('isValid')) {
} else {
  • I tried your solution in a setInterval, but console say valid while the form is not completed, don't understand why
    – Kevin ami
    Nov 4, 2022 at 16:31
  • I tried also shippingForm.validate(), it does not detect errors
    – Kevin ami
    Nov 8, 2022 at 9:11
  • Ok, let me check.
    – Tu Van
    Nov 8, 2022 at 9:13

Your Answer

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

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