diff --git a/Amasty_GiftCard/web/js/giftcard-mixin.js b/Amasty_GiftCard/web/js/giftcard-mixin.js index 1d73dac24..5eebbe3f3 100644 --- a/Amasty_GiftCard/web/js/giftcard-mixin.js +++ b/Amasty_GiftCard/web/js/giftcard-mixin.js @@ -1,4 +1,4 @@ -define([], function () { +define(['jquery'], function ($) { 'use strict'; return function (Component) { @@ -7,7 +7,18 @@ define([], function () { element: { addToCardButton: '.tocart', } - } + }, + validateForm: function (event) { + var textareaValue = $(this.element.textarea).val(); + var isValidTextarea = textareaValue ? textareaValue.length < this.maxLength : true; + + if ($('#product_addtocart_form').validate().form() && isValidTextarea) { + return; + } + + event.preventDefault(); + event.stopPropagation(); + }, }); }; });