I already did server side data validation using the hook 'elementor_pro/forms/validation' and it's working fine.
Now in addition, I would like to do client side data validation before submitting the form to fix invalid data straight away avoiding a round trip to the server.
I would like to do custom validation using javascript and not using the default browser tooltip bubble.
I added this code and the validation works fine, errors messages are displayed on the form. But the form is still submitted when fields input are invalid.
document.addEventListener('submit', (e)=>{
// this is my custom validation function
validateForm(e);
})
How to prevent the form to submit ? preventDefault() function doesn't work as the form submit is done via Ajax.
Best regards,