javascript - Calling jquery function with function(e) parameters from another jquery function -


        $("#submitbutton").click(function(e){             e.preventdefault();              if (!$('#formvalidator').data('bootstrapvalidator').isvalid())                  $('#formvalidator').bootstrapvalidator('validate');             if  (!$('#jobvalidator').data('bootstrapvalidator').isvalid())                 $('#jobvalidator').bootstrapvalidator('validate');              if(($('#formvalidator').data('bootstrapvalidator').isvalid()) & ($('#jobvalidator').data('bootstrapvalidator').isvalid()))             {                 var clickbutton = document.getelementbyid("<%=savebutton.clientid %>");                 clickbutton.click();             }         });          $(document).keypress(function(e) {             if(e.which == 13) {                  $("#submitbutton").click();             }         }); 

i want $(document).keypress(function(e) captures enter key on page call $(document).keypress(function(e) validates form , call code behind.

both of functions work on own, dont know how call button click function enter key function. because have pass (function(e) , havent been able figure out how. cheers.

rather pass anonymous functions, can save reference function in variable, , pass reference jquery. example:

var validatefunc = function(e) {     e.preventdefault();      if (!$('#formvalidator').data('bootstrapvalidator').isvalid())          $('#formvalidator').bootstrapvalidator('validate');     if  (!$('#jobvalidator').data('bootstrapvalidator').isvalid())         $('#jobvalidator').bootstrapvalidator('validate');      if(($('#formvalidator').data('bootstrapvalidator').isvalid()) & ($('#jobvalidator').data('bootstrapvalidator').isvalid()))     {         var clickbutton = document.getelementbyid("<%=savebutton.clientid %>");         clickbutton.click();     } };  $("#submitbutton").click(validatefunc);  $(document).keypress(function(e) {     if(e.which == 13) {         validatefunc(e);     } }); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -