Home » Javascript » Article
Multiple submit buttons with form validation
|
| Article by: | Paul Eckert (8/30/2005) |
|
| Sponsored by: | FindMyHosting - Web Hosting Search |
| Summary: | This code shows how to redirect a user to multiple sites, depending on which submit button he presses, but only after the form validates correctly. |
|
| Viewed: 6429 times |
Rating (4 votes): |
|
3.8 out of 5 |
|
|
|
Multiple submit buttons with form validation
This is a very simple example of how to code a form to allow redirection to any of 3 sites depending on which button the user presses, but only after the form validates properly.
In this example, at least one of the checkboxes must be checked before the redirection buttons at the bottom actually send the user to the alternate page or script. If you have text fields or whatever on your form, your validate function will be more complicated. For instance, you might have:
To make this code snippet work, you must add:
a. 3 real destinations or action routes (identified by action1.html, action2.cgi, and action3.html in my code)
b. 3 button images corresponding to:
submit1_icon.jpg, submit2_icon.jpg, submit3_icon.jpg
in your /images directory.
Then just copy it and paste it into test.html or whatever and browse to it. Voila!
|
|
View highlighted Comments
User Comments on 'Multiple submit buttons with form validation'
|
|
|
|
To post comments you need to become a member. If you are already a member, please log in .
| RELATED ARTICLES |
Javascript Onload Event by Jeff Anderson
Sometimes you need to perform an action immediatley after the page has loaded. That's when the onLoad Event Handler comes in handy |
 |
Javascript - Enable and Disable form elements by Jeff Anderson
This is a relatively little known and under-used feature of javascript which can be very useful in guiding a user through a form. Using the disabled tag, you can switch on and off elements in a form. |
 |
Form Validation Function by Jeff Anderson
A javascript validation function that you can use to validate all types of forms. |
 |
Check IsNumeric Function by Jeff Anderson
A javascript validation function to check whether the details entered by a user are numeric. |
 |
JavaScript Field Is Empty Form Validation by Jeff Anderson
This javascript function allows you to check whether a form field has been completed or not. |
 |
Check Email Validation Function by Jeff Anderson
A javascript validation function to check whether the user has entered a valid email address in a form. |
 |
Multiple submit buttons on a single form by Kiran Pai
This script shows you how to submit the contents of a form to different programs depending on which Submit button you press. Additionally it also shows how to call two different functions when you press the Submit button. |
 |
Validate Form and Disable Submit Button by Marylou Marks
I have a form that validates info, but I also want to disable the submit button. The disable part worked before adding the form validating. |
 |
Simple date validation by Chris Hogben
function that takes a date in three parts, day, month and year - returns true if it's a valid date. |
 |
Multiple submit buttons with form validation by Paul Eckert
This code shows how to redirect a user to multiple sites, depending on which submit button he presses, but only after the form validates correctly. |
 |
| |