Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - Form Require Hidden Input Not Working

 
Thread Tools Search this Thread
Old 01-17-2006, 04:32 AM   #1
Default Form Require Hidden Input Not Working


The last input in my form is hidden.
<input type="hidden" name="required" value="name,email,phone,organization"/>
I have been out of the loop with writing code for a while. This validates,
but does not work. I am trying to avoid a user clicking on the send button
and submitting a blank form. The form goes to a PHP handler and all that
works fine.
Any thoughts?
Thanks

--
Christopher
www.teamadness.com
slightly true stories of tea drinking




tea-mad brit
  Reply With Quote
Old 01-17-2006, 06:55 AM   #2
Ed Jay
 
Posts: n/a
Default Re: Form Require Hidden Input Not Working
"tea-mad brit" <> wrote:

>The last input in my form is hidden.
><input type="hidden" name="required" value="name,email,phone,organization"/>
>I have been out of the loop with writing code for a while. This validates,
>but does not work. I am trying to avoid a user clicking on the send button
>and submitting a blank form. The form goes to a PHP handler and all that
>works fine.
>Any thoughts?
>Thanks


You might try using onsubmit="return somefunction();" and having
somefunction() check the form field(s) for empty. If the form is empty,
return false. If the form isn't empty, return true.

If you want, using innerHTML, you can have somefunction() print an error
message to the screen before returning false..

--
Ed Jay (remove M to respond by email)


Ed Jay
  Reply With Quote
Old 01-17-2006, 09:08 AM   #3
David Dorward
 
Posts: n/a
Default Re: Form Require Hidden Input Not Working
tea-mad brit wrote:

> The last input in my form is hidden.
> <input type="hidden" name="required"
> value="name,email,phone,organization"/>


If you plan to serve your XHTML as text/html[1], then appendix C requires a
space before that /.

> I have been out of the loop with writing code for a while. This validates,
> but does not work. I am trying to avoid a user clicking on the send button
> and submitting a blank form. The form goes to a PHP handler and all that
> works fine.


What that code should do is submit to the server side script the data in the
value attribute attached to the key that is the value of the name field.
Nothing about it actually makes any fields required.

The server side script can then check what values were submitted based on
that field and complain to the user if they haven't entered the required
values.

You could also do something similar with client side JavaScript.

Either way, user's can modify the required input if the want to, so its no
good if you really want to prevent people not submitting those fields.
(OTOH, it does make it rather difficult for the user to have a successfully
processed form by accident).

[1] If you don't then you are going to have a really limited audience, if
you do then there isn't any point in using XHTML instead of the better
supported HTML 4.01 in the first place.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


David Dorward
  Reply With Quote
Old 01-17-2006, 04:23 PM   #4
tea-mad brit
 
Posts: n/a
Default Re: Form Require Hidden Input Not Working

> Either way, user's can modify the required input if the want to, so its no
> good if you really want to prevent people not submitting those fields.
> (OTOH, it does make it rather difficult for the user to have a
> successfully
> processed form by accident).
>
> [1] If you don't then you are going to have a really limited audience, if
> you do then there isn't any point in using XHTML instead of the better
> supported HTML 4.01 in the first place.
>
> --
> David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
> Home is where the ~/.bashrc is


Yes, I just need to help the user avoid a mistake and get a false count on
how many people fill out the form.

I don't know anything about JS but a little PHP. If I understand correctly,
I need to modify the server side script and that the required stuff in the
input form isn't doing anything?
Thanks.




tea-mad brit
  Reply With Quote
Old 01-17-2006, 05:21 PM   #5
David Dorward
 
Posts: n/a
Default Re: Form Require Hidden Input Not Working
tea-mad brit wrote:

> I don't know anything about JS but a little PHP. If I understand
> correctly, I need to modify the server side script and that the required
> stuff in the input form isn't doing anything?


The required stuff in the input form is providing data that gets sent to the
server. The server side script could use this to decide what to test for in
its sanity checking routines.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


David Dorward
  Reply With Quote
Old 01-17-2006, 11:24 PM   #6
gerg
 
Posts: n/a
Default Re: Form Require Hidden Input Not Working
David Dorward wrote:
> tea-mad brit wrote:
>
>
>>I don't know anything about JS but a little PHP. If I understand
>>correctly, I need to modify the server side script and that the required
>>stuff in the input form isn't doing anything?

>
>
> The required stuff in the input form is providing data that gets sent to the
> server. The server side script could use this to decide what to test for in
> its sanity checking routines.
>


use something like this:

processor.php

<?

session_start();

// the $_POST variables should be the same as your form names.

if( (empty($_POST['email'])) || (empty($_POST['name'])) ||
(empty($_POST['phone'])) ){

// return to the form and display an error message.

$_SESSION['errormessage']="Please fill out all form fields.";
header("Location:http://www.mysite.com/myform.php");
exit();

}
else
{
// execute code that should happen if all fields are filled in.
}

?>


myform.php

<?

//this line makes available any session variables already set, like the
error message above.

session_start();

//if there is an error message available, display it

if($_SESSION['errormessage']){
echo $_SESSION['errormessage'];
}

?>

Your form would then go here.

Hope that helps.

Greg


gerg
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wonderful data input with web reporting tool freezea Software 0 09-09-2009 05:30 AM
PIX 6.3 - Outbound traffic not working khurri Hardware 1 06-26-2009 02:39 PM
DVD Recorder-DV input & Hard Drive ? Marion DVD Video 7 05-16-2004 06:31 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46