0

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
2
  • can you provide the rest of your script Commented Jun 20, 2012 at 11:18
  • i want to trigger this... $('#theform').submit( function() { }); Commented Jun 20, 2012 at 11:22

2 Answers 2

1

fixed, by placing inside this

 jQuery(document).ready(function($) {
 // Code using $ as usual goes here. 
 });
answered Jun 20, 2012 at 11:31
Sign up to request clarification or add additional context in comments.

Comments

1

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;
});

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.