jquery - Show a Modal Window on Form Submit and Submit form While Modal "Accept" Button is clicked? -


i have form validations in place, when submit form have shown bootstrap modal window, know modal window has 2 buttons accept , cancel, on click of accept button want form submit , on cancel close modal.

var errormessages = [];      $("#f").submit(function(event){           $("input,select,textarea").not("[type=submit]").each(function (i, el) {            errormessages = errormessages.concat(                $(this).triggerhandler("validation.validation")            );          });          if(errormessages.length==0){          $('#mymodal').modal("show");     $("#agreesubmit").on('click',function(){         $("#mymodal").modal("hide");        return true;         });     }     event.preventdefault();     }); 

now stuck @ click of #agreesubmit button when click it, want form submit , not sure here.

does help? need "flag" agreement made, , submit form. i've shown data-attribute being used it's neat , simple. i've not tested code it's logically sound.

$('#f').on('submit', function(e) {   if( $(this).data('form-agree') !== true ) {     e.preventdefault();     // fire modal logic here.   } });  $('#agreesubmit').on('click', function() {   $('#f').data('form-agree', true).submit(); }); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -