My goal is to disable a ‘make payment’ button until the form is filled out.
I know that there are event listeners to detect things, including:
- errorClassAdded
- errorClassRemoved
- focusClassAdded
- focusClassRemoved
But I can’t seem to devise a way to use these to detect if the form is fully filled out.
I tried to setup something where the ‘focusClassRemoved’ triggers card.tokenize(), which is then checked for errors, but it triggers errors once the first form field is unfocused and displays the errors on the form, which is obviously not a good UX experience.
What I’m really after is a function that is being called each time a field changes that lists errors (even for fields the customer hasn’t filled out yet), but doesn’t trigger the errors to be displayed.
for example:
the customer begins to fill out the ‘card’ field:
some ‘onChange’ functions runs => {errors:[‘card’,‘exp’,‘cvv’,‘zip’]}
the customer begins to fill out the ‘exp’ field:
some ‘onChange’ functions runs => {errors:[‘exp’,‘cvv’,‘zip’]}
the customer begins to fill out the ‘cvv’ field:
some ‘onChange’ functions runs => {errors:[‘cvv’,‘zip’]}
the customer begins to fill out the ‘zip’ field:
some ‘onChange’ functions runs => {errors:[‘zip’]}
the customer completes 5 digits on the ‘zip’ field:
some ‘onChange’ functions runs => {errors:[]}
Is this just not doable?
thanks!