Click to See Complete Forum and Search --> : Need little help with form please...


swedecom
06-08-2003, 07:14 AM
Hi everyone,

I have a site with a form on it
( http://www.swedecom.com/orderdoman.htm ).
I have some feilds with a "*" symbol beside it. I want this fields to be required in order to submit the form.

Anyone know what I have to do to get this to work??

Thanks alot :)

//Swedecom

IrDa
06-08-2003, 07:34 AM
You may try the following

<SCRIPT language="JavaScript">

function check_form()
{
valid = true; // assume valid
if (doc.form.fullname.value.length == 0)
{ valid = false; alert('Please fill in the name');
doc.form.fullname.focus(); return false; }
}
</SCRIPT>

<INPUT type="text" name="fullname" size="21" maxlength="21" value=>
<INPUT TYPE=button NAME="finished" VALUE="Send Now" onclick=check_form()>

swedecom
06-08-2003, 07:41 AM
Thanks alot for your help!

Now, another small question. Is there any way I can program the form to send the users IP in the mail??

Thanks again...

//Swedecom

Charles
06-08-2003, 07:43 AM
In the document head:

<script type="text/javascript">
<!--
function validateForm (f) {
var required = ['Agare_Namn_Foretag', 'Toppdoman'];
for (j=0; j<required.length; j++) {
var e = f[required[j]];
switch (e.type) {
case 'text' :
if (e.value.length == 0) {alert ('Fields marked with astrices are required.'); e.focus(); return false}
break;
case 'select-one' :
if (e.selectedIndex < 0) {alert ('Fields marked with astrices are required.'); e.focus(); return false}
}
}
return false;
}
// -->
</script>

And then as the form tag:

<FORM METHOD=POST ACTION="/cgi-bin/formmail.cgi" onsubmit="return validateForm(this)">

swedecom
06-08-2003, 08:06 AM
Thanks again :)

Is there any way I can program the form to send the users IP-number in the mail??

//Swedecom

pyro
06-08-2003, 08:39 AM
I see you are using formmial.pl (something I would not recommend). In the documentation, it will tell you how to include the IP number in the email...

swedecom
06-08-2003, 08:41 AM
Thanks Pyro and Dave Clark:)

Pyro, what are you recommend instread of formamail.pl ??

//Swedeom

pyro
06-08-2003, 08:54 AM
Basically, anything... :) Formmail was listed at number 3 for the top 10 attacks for the 1st quarter of 2002 ( http://www.securityfocus.com/corporate/research/top10attacks_q1_2002.shtml ) If a PHP script is ok, please look at http://forums.webdeveloper.com/showthread.php?s=&threadid=9543. If not, post in the CGI forum and I'm sure someone will help you...