0

I have a Shipping & Billing page in my OnePage Checkout. On that page I have two tabs. One tab shows saved addresses and the other tab is for customers to add a new address. If no saved address exists I have javascript that switches the active tab to display the new address tab. I want to invoke validation at that point to show the Varien form field validation errors that would normally be displayed when you hit submit and miss filling out fields properly.

How could I invoke the validation without doing a submit?

1 Answer 1

2

Take a look at js/prototype/validation.js

.....
onSubmit :  function(ev){
    if(!this.validate()) Event.stop(ev);
},
validate : function() {
    var result = false;
    var useTitles = this.options.useTitles;
    var callback = this.options.onElementValidate;
...

Try

//var contactForm = new VarienForm('contactForm', false);
contactForm.validator.validate()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.