QUOTE(jason95 @ Apr 1 2011, 07:02 AM)
Hey there,
I have a slight problem with a contact form for my website,I added the form validation script to the top of my form,so when I am using notepad and enter input fields and submit, the blocker pops down warning of a script access.Once I allow the access warning my validation "you must enter firstname" and so on work fine.
My validation wont work when users try to use the contact form?
Here is the full html code and java added in. Thanks for any info!
<html>
<head>
<title>JavaScript Form Validation Script</title>
<script language="JavaScript" type="text/JavaScript">
function checkForm(thisform)
{
if(thisform.Firstname.value=='')
{
alert("Firstname field is required. Please fill it in.");
return false;
}
if(thisform.Lastname.value=='')
{
alert("Lastname field is required. Please fill it in.");
return false;
}
if(thisform.Address.value=='')
{
alert("Address field is required. Please fill it in.");
return false;
}
if(thisform.Email.value=='')
{
alert("Email field is required. Please fill it in.");
return false;
}
//if all is OK submit the form
thisform.submit();
}
</script>
<body>
<form name="form1" id="form1" method="post" action="--SCRIPT.PHP--">
<table width="400px" border="0px" bgcolor="#ffffff" cellpadding="2" cellspacing="2">
<tr><td width="150px" align="left">
<strong>Firstname:</td>
<td align="left" ><input name="Firstname" type="text" id="Firstname" size="15"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>
</tr>
<tr>
<td><strong>Lastname:</td>
<td><input name="Lastname" type="text" id="Lastname" size="15"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>
</tr>
<tr>
<td><strong>Address:</td>
<td><input name="Address" type="text" id="Address" size="30"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>
</tr>
<tr>
<td><strong>Email:</td>
<td><input name="Email" type="text" id="Email" size="25"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>
<td><input name="Submit" type="button" id="Submit" onclick="checkForm(this.form)" value="Submit" /></td>