Log in

View Full Version : Form



Determined..
10-30-2005, 11:26 PM
I have a form and im using javascript to make fields all be filled otherwise no send (but i want to make the email field optional donno how)
heres my script (i've excluded my JavaScript i will add if anyone can tell how to make my Email field not required.):
<html>

<head>

<title>My Domain Contact Us Form</title>
</head>

<center><h2> Contact us </h2></center>
<FORM ACTION="http://www.my-domain-site.com" METHOD ="POST">
<p>
Name:<INPUT TYPE="text" name="first" size="20">
</p>
<p>
Email:
<INPUT TYPE="text" name="middle" size="20">
</P>
<p>
Contact Reason:
<INPUT TYPE="text" name="last" size="20">
</p>
<p>
Please enter text in field below:<br>
<TEXTAREA NAME="Answer" Rows="5" COLS="20" WRAP>
</TEXTAREA>
</P>
<INPUT TYPE="Submit" Value="Submit Form">
<INPUT TYPE="Reset" Value= "Clear Form">
</center>
</FORM>
</body>

</html>

simonf
11-01-2005, 05:49 AM
Like this.....

<script>
function Area_empty() {
var empty = true
for (var i=0;i<frMain.elements['Area[]'].length;i++) {
if (frMain.elements['Area[]'][i].checked) {
empty = false;
}
}
return empty;
}

function form_go() {
if (frMain.Name.value == '') {
alert('Please enter your Name');
return false;
} else if ((frMain.Email.value == '') && (frMain.Tel.value == '') ) {
alert('Please enter yout telephone number or email address')
return false;
} else if (Area_empty()) {
alert('Please select an Area');
return false;
} else {
return true;
}
}
</script>