Computing.Net > Forums > Web Development > JavaScript Validation - Form Action

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

JavaScript Validation - Form Action

Reply to Message Icon

Name: drsmartman
Date: March 5, 2004 at 20:53:55 Pacific
OS: Win XP
CPU/Ram: P4 2.4
Comment:

Quick question. Just started using JavaScript again after a few years off. I know there is a wealth of form validation out there, but for some reason I return false (see below) and the form still takes action. Isn't the form NOT supposed to take the "action" if the function below returns false?

<form name="regForm" onSubmit="return addToShoppingCart()" action="registration.php?cf=2" method="post">

I know addToShoppingCart() returns false.

Any ideas? What am I missing?

Thanks as always.



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: March 6, 2004 at 21:46:12 Pacific
Reply:

Instead of using a submit button, I use just a regular HTML button which calls a function. That function (if the validations are met) will submit the form. I find that this method gives me much more flexibility.


Michael J


0

Response Number 2
Name: airski
Date: March 9, 2004 at 21:52:40 Pacific
Reply:

Here is a simple form validation to test if a text box has no value. If the user does not enter something it won't submit. Your call is correct so it must be something below.

function ValidateForm()
{
x=document.form

if (x.fieldname.value == "")
{
return false
}
return true
}


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: JavaScript Validation - Form Action

validate form with rollover button www.computing.net/answers/webdevel/validate-form-with-rollover-button/99.html

form action= www.computing.net/answers/webdevel/form-action/478.html

form action to text file www.computing.net/answers/webdevel/form-action-to-text-file/2516.html