<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function Validate()
{
var sName=document.frmContact.txtName.value;
var stxtPhone=document.frmContact.txtPhone.value;
var sEmail=document.frmContact.txtEmail.value;
var sComments=document.frmContact.txtComments.value;
if(sName == "")
{
alert("Please provide your name");
document.frmContact.txtName.focus();
return false;
}
if(stxtPhone!= ""){
if(isNaN(stxtPhone)){
alert("Please Enter Valid Number");
document.frmContact.txtPhone.focus();
return false;
}
}else{
alert("Please Enter your Phone Number");
document.frmContact.txtPhone.focus();
return false;
}
if(sEmail == "")
{
alert("Please provide your email");
document.frmContact.txtEmail.focus();
return false;
}
var regex = /^[a-zA-Z0-9_.]+@([a-zA-Z0-9_.]+\.)+[a-zA-Z0-9.-]{2,3}$/;
match = regex.test(sEmail)
if(! match)
{
alert("Invalid email, please provide valid email");
document.frmContact.txtEmail.focus();
return false;
}
if(sComments =="")
{
alert("Please provide your comments");
document.frmContact.txtComments.focus();
return false;
}
if(document.frmContact.captcha_code.value != document.frmContact.txtSecCode.value){
alert("Security code doesnot match. Please enter valid security code.");
document.frmContact.txtSecCode.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form method="post" action="" name="frmContact" id="frmContact" onSubmit="return Validate()">
<table width="90%" border="0" cellpadding="0" cellspacing="1" class="text">
<tr>
<td colspan="3" height="5" align="left" valign="middle" class="white_text"></td>
</tr>
<tr>
<td width="33%" height="25" align="left" valign="middle" class="green"><span class="mandatory">* </span>Name</td>
<td width="6%" align="left" valign="middle" class="white_text">:</td>
<td width="61%" align="left" valign="middle"><input name="txtName" type="text" class="forTextfield" size="30" maxlength="50"/></td>
</tr>
<tr>
<td height="25" align="left" valign="middle" class="green"><span class="mandatory">* </span>Phone</td>
<td width="6%" align="left" valign="middle" class="white_text">:</td>
<td align="left" valign="middle"><input name="txtPhone" type="text" class="forTextfield" size="30" maxlength="15"/></td>
</tr>
<tr>
<td height="25" align="left" valign="middle" class="green"><span class="mandatory">* </span>Email</td>
<td width="6%" align="left" valign="middle" class="white_text">:</td>
<td align="left" valign="middle"><input name="txtEmail" type="text" class="forTextfield" size="30" maxlength="50"/></td>
</tr>
<tr>
<td align="left" class="green" valign="middle"><span class="mandatory"> </span> Address</td>
<td width="6%" class="white_text" align="left" valign="middle">:</td>
<td align="left" valign="middle"><textarea name="txtAddress" rows="2" cols="25" class="forTextfield"></textarea></td>
</tr>
<tr>
<td align="left" class="green" valign="middle"><span class="mandatory">* </span>Enquiry</td>
<td width="6%" class="white_text" align="left" valign="middle">:</td>
<td align="left" valign="middle"><textarea name="txtComments" rows="2" cols="25" class="forTextfield"></textarea></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle"> </td>
<td height="60" align="left" valign="middle"><img src="captcha/CaptchaSecurityImages.php?width=100&height=40&characters=5" />
<input type="hidden" name="captcha_code" value="<?=$_SESSION['code']?>"></td>
</tr>
<tr>
<td align="left" valign="middle" class="green">Security Code</td>
<td align="left" valign="middle" class="white_text">:</td>
<td align="left" valign="middle"><input type="text" name="txtSecCode" class="forTextfield" id="txtSecCode"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle"> </td>
<td align="left" valign="middle"> </td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle"> </td>
<td align="left" valign="middle"><input name="hid_submit" type="submit" class="forButton" id="hid_submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>
No comments:
Post a Comment