Websnippetz

Get cool snippets on php, css, jQuery, Magento and wordpress

Magento: Do some action after magento form validation

In Magento, we are having default validation function called VarienForm, if we pass our form id it will validate the input fields based on the class we specified into it. Ex. required-entry, validate-email. If we want to do some action before submitting the form, follow below code to catch the success action.

    var dataForm = new VarienForm('reach-form-validate');
    $('reach_us_submit').observe('click', function(){
       if(dataForm.validator.validate()){
            jQuery('#reach_us_submit').attr('disabled','disabled');
            dataForm.form.submit();
        } else {
            jQuery('#reach_us_submit').removeAttr('disabled');
        }
    }.bind(dataForm));

karthi s

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: