[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-02-11
3
Medium Priority
?
929 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.
0
Comment
Question by:Glen_Mac
3 Comments
 
LVL 16

Accepted Solution

by:
anoyes earned 1000 total points
ID: 23636048
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

0
 
LVL 1

Expert Comment

by:leonthelion
ID: 33112252
onSubmit may be a better cadidate for this purpose than onclick.
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 34615266
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

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month18 days, 22 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question