0

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');
0

Yes, VarienForm has been depreciated in Magento2.

You can try it;

<script type="text/javascript">
require([
    'jquery',
    'mage/mage'
], function($){

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

});
</script>

For details, you can look at this answer.

Magento 2 - Form Validation

1
  • 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.