I'm trying to add an event like 'keyup: validationSuccess' to all input fields on the checkout. I have overwritten input.html and added the Js to Shipping.js but now when i go to checkout/cart.html I get an error because of course the validationSuccess function doesn't exist on the Cart JS. So I need the function on all inputs on the Checkout but not on the Cart so overwriting input doesn't work. How do I do this the right way?
You can do it in your overriden input.html file be setting conditions,
Final code will be,
<!-- ko if: window.checkoutConfig.checkoutUrl.replace(/(\/#|\/|#)$/, '') == window.location.href --> <!-- for checkout page --> <input class="input-text aaaaaaaa" type="text" data-bind=" value: value, valueUpdate: 'keyup', hasFocus: focused, attr: { name: inputName, placeholder: placeholder, 'aria-describedby': getDescriptionId(), 'aria-required': required, 'aria-invalid': error() ? true : 'false', id: uid, disabled: disabled }" /> <!-- /ko --> <!-- ko ifnot: window.checkoutConfig.checkoutUrl.replace(/(\/#|\/|#)$/, '') == window.location.href --> <!-- for other pages --> <input class="input-text aaaaaaaa" type="text" data-bind=" value: value, valueUpdate: 'keyup', hasFocus: focused, attr: { name: inputName, placeholder: placeholder, 'aria-describedby': getDescriptionId(), 'aria-required': required, 'aria-invalid': error() ? true : 'false', id: uid, disabled: disabled }" /> <!-- /ko -->
I feel like there should be a better way using events and observables but i'm not sure what event get's fired on keyup?