1

I have additional input and select fields in shipping method.

In checkout at shipping step all forms validates by this code:

module-checkout/view/frontend/web/js/view/shipping.js

            saveNewAddress: function () {
                var addressData,
                newShippingAddress;

            this.source.set('params.invalid', false);
            this.source.trigger('shippingAddress.data.validate');

            if (!this.source.get('params.invalid')) {
                addressData = this.source.get('shippingAddress');
                // if user clicked the checkbox, its value is true or false. Need to convert.
                addressData.save_in_address_book = this.saveInAddressBook ? 1 : 0;

                // New address must be selected as a shipping address
                newShippingAddress = createShippingAddress(addressData);
                selectShippingAddress(newShippingAddress);
                checkoutData.setSelectedShippingAddress(newShippingAddress.getKey());
                checkoutData.setNewCustomerShippingAddress(addressData);
                this.getPopUp().closeModal();
                this.isNewAddressAdded(true);
            }
        }

This code triggers all inputs and selects on shipping step

            this.source.set('params.invalid', false);
            this.source.trigger('shippingAddress.data.validate');

I want to validate only

          <!-- ko foreach: getRegion('address-list-additional-               addresses') -->
            <!-- ko template: getTemplate() --><!-- /ko -->
            <!--/ko-->

in shipping.html

This is UiClass registry.get('index = address-list-additional-addresses');


Code

            this.source.set('params.invalid', false);
            this.source.trigger('address-list-additional-addresses.data.validate');

Fires nothing.

Thanks for your answers:)

  • I need to validade checkout form I am autocompleting it but when I hit button next even thought is populated it says it's required have you found a solution to validate?thanks – Juliano Vargas Jun 7 '18 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.