formvalidation.io validate form on class click

petewinter
petewinter used Ask the Experts™
on
I am using this form validation script: http://formvalidation.io/settings/

Can you please help me find how I change my code to submit the form on click of element with the class name of "csaf-stage1".

$(document).ready(function() {
		
	$('#csaf-form').formValidation({
		
		// live: 'enabled', // Default value
		trigger: 'input change keyup',
		fields: {
			default_deposit_amount: {
                validators: {
                    greaterThan: {
                        value: getDepositAmount,
                        message: 'The higher deposit must be 5% or greater'
                    }
                }
            }
        }
				
	}).on('success.form.fv', function(e) {
		
	// success code here
		
    });
				
});

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017
Commented:
Try the following code comments inside:
$(document).ready(function() {
		
	$('#csaf-form').formValidation({
		
		// live: 'enabled', // Default value
		trigger: 'input change keyup',
		fields: {
			default_deposit_amount: {
                validators: {
                    greaterThan: {
                        value: getDepositAmount,
                        message: 'The higher deposit must be 5% or greater'
                    }
                }
            }
        }
	//As documentation said I use on event with selector the class='.csaf-stage1' to reigger the submit			
	}).on('click', '.csaf-stage1', function(e){
      //I set a var $form 
      var $form = $('.class_of_the_form'),
                fv    = $form.data('formValidation');
	//The ajax function triggers via click event	
	       $.ajax({
                url: $form.attr('action'),
                type: 'POST',
                data: $form.serialize(),
                success: function(result) {
                   console(result);
                }
            });
		
    });
				
});

Open in new window

Author

Commented:
Thanks, but my form is not validating so I must have done something wrong if you can please check:

http://dev.cmyuk.com/csaf/

JQuery: http://dev.cmyuk.com/csaf/js/csaf.js

I basically want the form to submit when the "Next Step" text or if the "PURCHASE WITH FINANCE - CSAF" bar is clicked. So multiple trigger. Also you will notice the fields have live validation if you type in the loan value field.

Any idea what I am doing wrong?

Author

Commented:
Thanks, but all I need to do was to add the below to my original code.

$( ".csaf-stage1" ).click(function() {
             $("#csaf-form").submit();
      });
Distinguished Expert 2017

Commented:
I hope that someway I find a solution to your problem. I search a lot your code but my code based at this link.
Thanks a lot.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial