View Full Version : Trouble with return false on a form submit.

07-18-2009, 04:52 AM
Hello everyone,

This is my first post here, but reading through the others I'm sure someone will be able to help me.

I trying to build a client-side validator before running my validation in php.

I have a <form onSubmit="function(login name, login password)"> type deal and in my function, I'm returning false if certain criteria aren't met.

the form's action runs it back to the current URL where I have a php validator activated if the post data is recognized.

As of now, both are running, which tells me the form is being submit regardless of that return false.

Can any of you make sense of it?

<form onSubmit="myFunction()">


function myFunction() {
get values of inputs

run validator

if it doesn't pass,

return false;

else return true;

shouldn't that return false stop the php validator?

Shannon Blonk
07-18-2009, 05:03 AM
Your validation function is returning true/false, but you're not passing that result to onsubmit. Try
<form onsubmit="return myFunction()">