Magento 2 has basic validation if the field is not valid.
How to add custom validation to the checkout page which will add a green border and an inscription that notifies the user of a successful validation.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI found a quick solution, it is working amazing
var config = { config: { mixins: { 'mage/validation': { 'Expert_Checkout/js/mage/validation-mixin': true } } } };
define([ 'jquery' ], function ($) { 'use strict'; var widgetMixin = { _create: function() { $(this.element).find('input, textarea, select').on("change keyup", function(e){ $.validator.validateSingleElement(e.currentTarget) }); return this._super(); } }; return function (parentWidget) { $.widget('mage.validation', parentWidget, widgetMixin); return $.mage.validation; }; })
Now it will work on all forms and valdate field as user type and add class valid on success
Thanks