Is there a way to update this code to work with Magento2? I believe VarienForm has been depreciated in Magento2 but I can't find a similar JS constructor to get the object.

var AddToCartForm = new VarienForm('#my_form');

Yes, VarienForm has been depreciated in Magento2.

You can try it;

<script type="text/javascript">
], function($){

   var dataForm = $('#my_form');
   dataForm.mage('validation', {});


For details, you can look at this answer.

Magento 2 - Form Validation

  • Does this turn the form into an object for further manipulation the way VarienForm does?
    – Sam
    Jun 22 '20 at 15:36

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.