Forums
This topic is locked
I'd love some help with my form!
Posted 06 Feb 2006 16:04:33
1
has voted
06 Feb 2006 16:04:33 alex mcleod posted:
Hi,I have a form on a website I'm doing which links to a php file and sends the details to an email address. The client wants validation on the form, and although I validate in Dreamweaver, the form 'sends' even if the fields aren't filled in. Can anybody let me know what's going wrong? The website is www.ttpcc.org.uk and the form is on the home page.
many thanks in advance
Alex
Replies
Replied 07 Feb 2006 17:52:48
07 Feb 2006 17:52:48 B D replied:
I was searching for the same thing and found this link:
gnwda.org/tutorials/coding/forms.htm
I've never tried it myself but I think it's just saying to setup a hidden field with the values being the names of whatever fields you are requiring:
• required
Allows you to require that certain fields be filled in before the user can successfully submit the form. Put the names of all mandatory fields into this input tag (the example below requires the person's name and email address). Thus, if the required fields are left empty, the user will be notified of what they need to fill in and will be given a link back to the form.
<input type=hidden name="required" value="realname,email">
Let me know if this works.
brando
DMX | PHP | SQL
gnwda.org/tutorials/coding/forms.htm
I've never tried it myself but I think it's just saying to setup a hidden field with the values being the names of whatever fields you are requiring:
• required
Allows you to require that certain fields be filled in before the user can successfully submit the form. Put the names of all mandatory fields into this input tag (the example below requires the person's name and email address). Thus, if the required fields are left empty, the user will be notified of what they need to fill in and will be given a link back to the form.
<input type=hidden name="required" value="realname,email">
Let me know if this works.
brando
DMX | PHP | SQL
Replied 07 Feb 2006 18:05:06
07 Feb 2006 18:05:06 B D replied:
Here's a way to require with Javascript:
javascript.internet.com/forms/basic-validation.html
DMX | PHP | SQL
javascript.internet.com/forms/basic-validation.html
DMX | PHP | SQL
Replied 09 Feb 2006 19:51:29
09 Feb 2006 19:51:29 Roddy Dairion replied:
I had the same problem and what i did was to "combine" php and javascript together.
For e.g.
I checked if any of the fields was empty by doing this
<pre id=code><font face=courier size=2 id=code>
if ($POST[fieldname]==""
{
$text="You didn't fill fieldname";
}
$java="alert('You have not selected a $item yet'); return(false)"; </font id=code></pre id=code>
then i added this code to my submit button
<pre id=code><font face=courier size=2 id=code> input type="submit" name="btnsubmit" value="Submit" accesskey="s" onclick="<?=$java?>" />
</font id=code></pre id=code>
when you click and you page detects that there's a problem field empty it will display the error.
Hope it helps. Ders more to it but try the basic.
For e.g.
I checked if any of the fields was empty by doing this
<pre id=code><font face=courier size=2 id=code>
if ($POST[fieldname]==""
{
$text="You didn't fill fieldname";
}
$java="alert('You have not selected a $item yet'); return(false)"; </font id=code></pre id=code>
then i added this code to my submit button
<pre id=code><font face=courier size=2 id=code> input type="submit" name="btnsubmit" value="Submit" accesskey="s" onclick="<?=$java?>" />
</font id=code></pre id=code>
when you click and you page detects that there's a problem field empty it will display the error.
Hope it helps. Ders more to it but try the basic.