I have a validation script that runs when a user clicks the form submit button.
I want to pass variables to this form and auto execute the validation script by injecting a piece of code.
I have tried this:
$('#theform').submit();
but it bypasses the validation that would have happened had a user manually clicked the button.
is there a way to emulate a user 'click' and execute the form submit triggers.
asked Jun 20, 2012 at 11:17
brian wilson
4951 gold badge7 silver badges16 bronze badges
-
can you provide the rest of your scriptmgraph– mgraph2012年06月20日 11:18:04 +00:00Commented Jun 20, 2012 at 11:18
-
i want to trigger this... $('#theform').submit( function() { });brian wilson– brian wilson2012年06月20日 11:22:44 +00:00Commented Jun 20, 2012 at 11:22
2 Answers 2
fixed, by placing inside this
jQuery(document).ready(function($) {
// Code using $ as usual goes here.
});
answered Jun 20, 2012 at 11:31
brian wilson
4951 gold badge7 silver badges16 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Try this:
$("#theform").submit(function() {
// If the validation function returns true, then submit
if(my_validation_function())
return true;
// If the validation function returns flase, don't submit
return false;
});
answered Jun 20, 2012 at 11:29
Michael Bergquist Suarez
112 bronze badges
Comments
lang-js