Why does form continue to submit after return false?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Why does form continue to submit after return false?

Post by voltrader »

Why does the form continue to submit after this returns false?

Code: Select all

<?php
	if(password.value!="")
			{
			
			if(password.value != confirm_password.value)
			{
			alert("Passwords do not match");
			password.focus();
			return false;
			}
?>
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Use this for your submit button:

Code: Select all

<input type="submit" name="Submit" value="Submit" onClick="javascript:myFunction();return false;">
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

That wasn't enough info....


and for you javascript use:

Code: Select all

if(password.value != confirm_password.value) 
         &#123; 
         alert("Passwords do not match"); 
         password.focus(); 
         return false; 
         &#125;else&#123;
document.formname.submit();
&#125;
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Great, thanks... I'm going to give it a try
Post Reply