PDA

View Full Version : Help with forms please!


Steakaphagus
07-31-2008, 11:04 AM
Hi guys, wondered if anyone could help with some form questions?
I'm pretty new to Dreamweaver (well, I've actually spent a long, long time slowly learning from books etc). I've managed to build half a site, but now struggling with forms......
1. I'm putting the form elements into a table, but can't work out how to change the size of the text area - I want to be able to display the site's terms and conds in a box, and the only way it looks even slightly ok is with virtual wrap. Ideally I'd like the box to be wider so less scrolling is needed......
2. I'm trying to put in a checkbox to say that T&C has been read to allow form submission - when I go to the 'behaviours' and try to validate the form, it only lets me insist on text field/area inputs - how do I insist on the box being checked to allow submission?
3. How do I get CAPTCHA into the form? I've seen downloads being sold on the net, but wondered if DW had it built in somewhere (can't find it though....)
4. Spent a long time getting my head around CGI (thought of using formail) - is this the best way to process the forms? (have read about PHP on this site, and now confused as to which to use, or are they the same?)

Sorry to be asking so much, but I'm tearing my hair out and didn't have that much to lose in the first place!!!

edbr
07-31-2008, 11:14 AM
no 1 post your code
no 2 not with dw alone i think
no 3 good clear captcha tut http://frikk.tk/comments-273-03.15.06.htm
no 4 check franks formail has both cgi and php

Steakaphagus
07-31-2008, 11:57 AM
Hi edbr. I've posted the code below - it's only a very basic form, as you will see! I've only put in part of the Ts and Cs to save space....but as you see, it would be nice to have a text area that was larger so users have more lines to view at one time and less 'side to side' scrolling. At the moment it previews as a tiny 2-line box that only views a couple of words at a time.

Thanks for the other advice - will look at the captcha site




<table width="443" border="1">
<tr>
<td width="126"><div align="right">Name:</div></td>
<td width="10">&nbsp;</td>
<td width="285"><input type="text" name="textfield"></td>
</tr>
<tr>
<td><div align="right">e-mail:</div></td>
<td>&nbsp;</td>
<td><input type="text" name="textfield"></td>
</tr>
<tr>
<td><div align="right">Comments: </div></td>
<td>&nbsp;</td>
<td><textarea name="textarea" wrap="PHYSICAL"></textarea> </td>
</tr>
<tr>
<td valign="top"><div align="right">Terms and Conditions: </div></td>
<td>&nbsp;</td>
<td><p>
<textarea name="textarea">We reserve the right to remove or edit any content or material on this website at any time, without prior notice, and at our sole discretion without there being any liability on our part.
You accept that we may suspend the website at any time to perform changes or maintenance to the website, and during this time you will not have access to the website. You further accept that access to the website may be suspended due to circumstances beyond our control and that any suspension of access for any reason is not limited to any length of time. </textarea>
</p>
</td>
</tr>
<tr>
<td valign="top"><div align="right">I agree to the Terms and Conditions </div></td>
<td>&nbsp;</td>
<td><input type="checkbox" name="checkbox" value="checkbox"></td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>

davidj
07-31-2008, 12:00 PM
it looks nicer when your code example is wrapped in code tags and makes it more legible ^^

ayok
07-31-2008, 09:35 PM
For larger textarea, you can use CSS. Like.. #txtArea{width:234px; height:1000;}

For checkbox validation, you can use javascript like...
function valid(){
var check_Box= document.myform.checkBox.value
if (check_Box==""){
alert("Please check!")
return false
}
return true
}

Steakaphagus
07-31-2008, 10:54 PM
Hey ayok,
Thanks for the help, will give it a go.
Anyone have views on captcha fields? I'm not overly keen on using them as I know they annoy me, so may well put off other users....problem is I'm worried about waking up one day with an in-box crammed with spam. Any ideas as to more usable anti-spamming methods?.....would the use of checkbox validation throw a spambot or am I being just a teeny bit naive? (be gentle now, I'm new to this!!!)

domedia
08-01-2008, 12:18 AM
Any ideas as to more usable anti-spamming methods?.... A captcha method basically means verifying it is a human. There's many different ways you can do this. From using logic (2+2=?), to read text from an image, to just repeating a word (type "hello" in the next field).
"Checkbox validation through a spambot" <= this sentence doesn't really make any sense :-) What do you mean?

Steakaphagus
08-01-2008, 08:00 AM
Hi, by 'would the use of checkbox validation throw a spambot', I meant can spambots still cause problems with forms if you have a checkbox that needs to be ticked before the form is accepted? (ie a user agreement checkbox. Or can a spambot automatically 'tick' a box to allow submission of the form?) - I may be getting a bit confused here I guess! :roll: Basically, is a required tick in a checkbox a captcha method?
One more thing - if I do use validation in a form, will I also need server-side validation? I've heard that validation in a form can be by-passed (by switching off javascript???)

edbr
08-01-2008, 09:04 AM
i think validation is only server side but if you add javascript it will save time for genuine mistakes before the server, if you get what i mean.
as for automatic form fillers it might depend on the name of the checkbox.
captcha is so common these days most people understand the reason, but i prefer a easily readable image and not too complex 3 or 4 numbers will limit most spam

edbr
08-01-2008, 09:19 AM
this is a simple validation i used, i added an image of 127 to the form (php)


if ($formval == "") {
echo "<h4>Please enter number in the anti spam box</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ($formval != 127) {
echo "<h4>Please enter correct number in the anti spam box</h4>";

}


with javascript on the form page
<script type="text/javascript">
function checkform()
{
if (document.form_enquire.formval.value == '')
{
// something is wrong
alert('Please fill in the anti spam box');
return false;
}
else if (document.form_enquire.formval.value != 127)
{
// something else is wrong
alert('You have entered the wrong number in the anti spam box');
return false;
}


return true;
}
</script>
it reduced spam well

Steakaphagus
08-01-2008, 03:38 PM
Thanks edbr, really appreciate all the help from you guys.
I guess that a simple captcha like you suggested shouldn't put off anyone really - as you say they are pretty commonplace and won't cause bother if they are straight-forward.
To be honest, I had been relying on Dreamweaver for the form validation, but found it restrictive - will try and get my teeth into Javascript a bit I think! Seems the way forward......

guiri
08-05-2008, 03:43 AM
Steak, although I don't know *hit about Dreamweaver (I'm here with a question) I KNOW the answer to the size of the field question.
If you click on your field, you will get a properties section at the bottom. In that, find where it says Char Width and simply set it to 50 or something and of course, make sure the other stuff kinda matches to look good.

Here's the code with the changes..


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="709" border="1">
<tr>
<td width="103"><div align="left">Name:</div></td>
<td width="8">&nbsp;</td>
<td width="583"><input type="text" name="textfield"></td>
</tr>
<tr>
<td><div align="left">e-mail:</div></td>
<td>&nbsp;</td>
<td><input type="text" name="textfield"></td>
</tr>
<tr>
<td><div align="left">Comments: </div></td>
<td>&nbsp;</td>
<td><textarea name="textarea" cols="50" wrap="PHYSICAL"></textarea> </td>
</tr>
<tr>
<td valign="top"><div align="left">Terms and Conditions: </div></td>
<td>&nbsp;</td>
<td><p>
<textarea name="textarea" cols="50">We reserve the right to remove or edit any content or material on this website at any time, without prior notice, and at our sole discretion without there being any liability on our part.
You accept that we may suspend the website at any time to perform changes or maintenance to the website, and during this time you will not have access to the website. You further accept that access to the website may be suspended due to circumstances beyond our control and that any suspension of access for any reason is not limited to any length of time. </textarea>
</p></td>
</tr>
<tr>
<td valign="top"><div align="left">I agree to the Terms and Conditions </div></td>
<td>&nbsp;</td>
<td><input type="checkbox" name="checkbox" value="checkbox"></td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</body>
</html>

George

Steakaphagus
08-05-2008, 10:48 AM
Thanks guiri,
Had a play with that, seems to work just right! Also found that putting a value into the 'num lines' box makes the box expand vertically. Cheers again!