The right way of doing this

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I want to use java script to validate the entry into a form and a php
script to do the posting. Each works fine on their own but how do I
combine them so that when the java returns true the php script is
called but otherwise its not.

<form method="post" name="CForm"  onsubmit="return VCForm();"

Any direction would be appreciated


Re: The right way of doing this

On 09/23/08 10:38 am, wrote:
Quoted text here. Click to load it
  What happens when JS is disabled? Or a naughty person submits a forged page?
  Where's the URL?

jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

Re: The right way of doing this

Thanks guys for the response,

I was hoping that my form header had somthing obvious wrong with it
but obviously not. I'll try to explain better.

The php script is very safe it check that the fields entered satisfy
certain criteria. If the java script dosnt run the PHP will basically
dump the form contents and not popultate the database. I'm a bit of a
programming dinosaur so I'm happy with the php.

So if java script isnt enable then the user will still be able to
submit but if they dont put meaning full data into the form it will be

The java script does some pre checking to assist the user with entry
so it more of a usabaility function.

My problem is that when the java script returns a failure (return
false;) it still goes ahead and runs the php, whithout allowing the
user to correct the mistake. If I remove the "action=3D"feedback.php"
then the form stays present and seems to do what I want it to,
(obviously, except actually doing the posting to the php part).

So basically if the VCform dosnt return true then dont do the PHP

I hope this give a better idea

Dave Mc


Quoted text here. Click to load it

Re: The right way of doing this

On 23 Sep 2008, wrote:

Quoted text here. Click to load it

There're several ways of doing that, but as Jim Moe queried, what happens
without j/s?  Well in general, no j/s means no submission.

Anyway, one way is to id the form, leave the action blank (or better yet a
url to some kind of an info page), and "fill in" the action with the
results of the j/s verification script.  Other ways include using
"onclick" with "return false", etc., but again: no j/s, no washee.

Neredbojias /
Great Sights and Sounds

Re: The right way of doing this

On Sep 23, 12:38=A0pm, wrote:
Quoted text here. Click to load it

There likely are many ways you could do this. I am inclined to use all
php when possible. See my demo page at =
and the text file at .
I want the user to select a year between 1 and 60000 inclusive and
nothing else. When the date is submitted, several tests are made using
php to make certain that only a number in the range selected is put in
the form. If anything else is used, the browser gets a notice and can
try again. There are all sorts of other test that one can uses for
text etc, when needed.

Site Timeline