We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

change hidden form field value and submit form on successful jquery validation result

Glen_Mac
Glen_Mac asked
on
Medium Priority
987 Views
Last Modified: 2012-05-06
Currently I use the onclick event on form button to change a hidden form variable and then submit the form. The hidden variable is used to determine which fusebox action to execute. I would like to incorporate jquery form validation, but cannot work out the best way to achieve this given the current approach to form submission. Any assistance or advice would be much appreciated.
Comment
Watch Question

Commented:
There's an amazing form validation plugin for jQuery here:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Once you have the validation set up, all you'd have to do is do

if ($('#formID').valid())
{
  //do form submission
}

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
onSubmit may be a better cadidate for this purpose than onclick.
To bring thogether both of experts above, you would have to use the code:
function checkForm(){
   // here you would have to check for valid fields
   // throught ajax request or inline
}

$('#formid').submit(function(e){
   checkForm();
   e.preventdefault();
});

Open in new window

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.