function Validateform()
{
name=Trim(document.getElementById("Name").value) ;
email=Trim(document.getElementById("Email").value) ;
contact=Trim(document.getElementById("ContactNo").value) ;
company=Trim(document.getElementById("Company").value) ;
querytype=Trim(document.getElementById("QueryType").value) ;
var str="";
flag=true;
//str=str+ "please enter your e-mail";
if(name=='Please enter your Name' || name=='Please enter Alphabets only' || name=='')
{
str="Please enter your Name\n";
document.getElementById("Name").focus();
flag=false;
//return false;
}
if(email=='Please enter your E-mail' || email=='Enter valid E-mail eg name@yahoo.com' || email=='')
{
str+="Please enter your E-mail Address\n";
document.getElementById("Email").focus();
flag=false;
//return false;
}
if(contact=='Please enter your Contact Number' || contact=='Enter valid Contact Number' || contact=='')
{
str+="Please enter your Contact Number\n";
document.getElementById("ContactNo").focus();
flag=false;
//return false;
}
if(company=='Please enter your Company Name' || company=='Enter valid Company Name' || company=='')
{
str+="Please enter your Company Name\n";
document.getElementById("Company").focus();
flag=false;
//return false;
}
if(querytype=='Query Type' || querytype=='' || querytype=='Query Type')
{
str+="Please select QueryType\n";
document.getElementById("QueryType").focus();
flag=false;
//return false;
}
if(flag==false)
{
alert(str);
return false;
}
else
return true;
}
function name_check()
{
name=Trim(document.getElementById("Name").value) ;
if(name=='Please enter your Name' || name=='Please enter Alphabets only')
{
document.getElementById("Name").value ='';
return false;
}
return true;
}
function email_check()
{
email=Trim(document.getElementById("Email").value) ;
if(email=='Please enter your E-mail' || email=='Enter valid E-mail eg name@yahoo.com')
{
document.getElementById("Email").value ='';
return false;
}
return true;
}
function contact_check()
{
contact=Trim(document.getElementById("ContactNo").value) ;
if(contact=='Please enter your Contact Number' || contact=='Enter valid Contact Number')
{
document.getElementById("ContactNo").value ='';
return false;
}
return true;
}
function Company_check()
{
contact=Trim(document.getElementById("Company").value) ;
if(contact=='Please enter your Company Name' || contact=='Please Enter valid Company Name')
{
document.getElementById("Company").value ='';
return false;
}
return true;
}
//for errors
function name_error()
{
obj=document.getElementById("formId");
name_obj=Trim(obj.Name.value);
//alert(name_obj);
if(name_obj=='Name' || name_obj=='')
{
document.getElementById("Name").value="Please enter your Name" ;
return false;
}
else
{
var regexLetter = /^[a-zA-Z-/\s]+$/;
if(!regexLetter.test(name_obj))
{
document.getElementById("Name").value="Please enter Alphabets only";
return false;
}
}
return true;
}
function email_error()
{
obj=document.getElementById("formId");
email_obj=Trim(obj.Email.value);
//alert(name_obj);
if(email_obj=='E-mail' || email_obj=='')
{
document.getElementById("Email").value="Please enter your E-mail" ;
return false;
}
else
{
var regexLetter = /^[a-zA-Z]+[a-zA-Z0-9._-]*\@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/;
if(!regexLetter.test(email_obj))
{
document.getElementById("Email").value="Enter valid E-mail eg name@yahoo.com";
return false;
}
}
return true;
}
function contact_error()
{
obj=document.getElementById("formId");
contact_obj=Trim(obj.ContactNo.value);
//alert(name_obj);
if(contact_obj=='Contact' || contact_obj=='')
{
document.getElementById("ContactNo").value="Please enter your Contact Number" ;
return false;
}
else
{
var regexLetter =/^\d{10}\d*$/;
if(!regexLetter.test(contact_obj))
{
document.getElementById("ContactNo").value="Enter valid Contact Number";
return false;
}
}
return true;
}
function Company_error()
{
obj=document.getElementById("formId");
company_obj=Trim(obj.Company.value);
//alert(name_obj);
if(company_obj=='Company' || company_obj=='')
{
document.getElementById("Company").value="Please enter your Company Name" ;
return false;
}
else
{
var regexLetter = /^[0-9a-zA-Z-/\s]+$/;
if(!regexLetter.test(company_obj))
{
document.getElementById("Company").value="Please Enter valid Company Name";
return false;
}
}
return true;
}
</script>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" id="formId" enctype="multipart/form-data" onsubmit="return Validateform();">
<div class="login_lft">
<div class="login_txt">Name<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Name" type="text" class="field" id="Name" maxlength="30" value='Please enter your Name' onblur="return name_error();" onclick="return name_check();" onfocus="return name_check();" tabindex="1" maxlength="50"/>
</label>
</div>
<div class="login_txt">E-mail Id<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Email" type="text" class="field" id="Email" value="Please enter your E-mail" onblur="return email_error();" onclick="return email_check();" onfocus="return email_check();" tabindex="3" maxlength="100"/>
</label>
</div>
<div class="login_field">
<label></label>
</div>
<div class="login_txt">Query Type<span class="red">*</span></div>
<div class="login_field">
<label>
<select name="QueryType" class="field" id="QueryType" tabindex="5" >
<option value="Query Type" selected="selected">Query Type</option>
<option value="Application Development & Design">Application Development & Design</option>
<option value="AMC">AMC</option>
<option value="Application Migration">Application Migration</option>
<option value="Data Centre">Data Centre</option>
<option value="FLMS Demo">FLMS Demo</option>
<option value="Mobile Application">Mobile Application</option>
<option value="Network">Network</option>
<option value="Remote infrastrucher Management">Remote infrastrucher Management</option>
<option value="Testing">Testing</option>
<option value="TIMS Demo">TIMS Demo</option>
<option value="Other Query">Other Query</option>
</select>
</label>
</div>
</div>
<div class="login_rgt">
<!--<div class="login_txt">Subject<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Subject" type="text" class="field" id="Subject" value="please enter Subject" onblur="return Subject_error();" onclick="return Subject_check();" onfocus="return Subject_check();" maxlength="50"/>
</label>
</div>-->
<div class="login_txt">Company Name<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Company" type="text" class="field" id="Company" value="Please enter your Company Name" onblur="return Company_error();" onclick="return Company_check();" onfocus="return Company_check();" tabindex="2" maxlength="200"/>
</label>
</div>
<div class="login_txt">Contact Number<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="ContactNo" type="text" class="field" id="ContactNo" maxlength="11" value="Please enter your Contact Number" onblur="return contact_error();" onclick="return contact_check();" onfocus="return contact_check();" tabindex="4" />
</label>
</div>
<!-- <div class="login_txt">Website URL</div>
<div class="login_field">
<label>
<input name="WebsiteURL" type="text" class="field" id="WebsiteURL" />
</label>
</div>-->
<div class="login_txt">Attach File</div>
<div class="login_field">
<label>
<input type="file" name="ContactFile" id="ContactFile" tabindex="6" />
</label>
</div>
<div class="login_field"></div>
</div>
<div class="clear"></div>
<div class="div_adjust">
</div>
<div class="div_adjust">
<div class="login_txt">Message<br /></div>
<label>
<textarea name="Description" class="field3" id="Description" cols="45" rows="5" tabindex="7" maxlength="100"></textarea>
</label>
<div class="clear"></div>
</div><br />
<div>
<table width="60%" border="0">
<tr>
<td><input name="button" type="submit" id="button" value="Submit" class="input_button" tabindex="8" /></td>
<td>Fields marked with <span class="red2"> * </span> are mandatory.</td>
</tr>
</table>
</div>
</form>
</div>
</div>
<?php } ?>
{
name=Trim(document.getElementById("Name").value) ;
email=Trim(document.getElementById("Email").value) ;
contact=Trim(document.getElementById("ContactNo").value) ;
company=Trim(document.getElementById("Company").value) ;
querytype=Trim(document.getElementById("QueryType").value) ;
var str="";
flag=true;
//str=str+ "please enter your e-mail";
if(name=='Please enter your Name' || name=='Please enter Alphabets only' || name=='')
{
str="Please enter your Name\n";
document.getElementById("Name").focus();
flag=false;
//return false;
}
if(email=='Please enter your E-mail' || email=='Enter valid E-mail eg name@yahoo.com' || email=='')
{
str+="Please enter your E-mail Address\n";
document.getElementById("Email").focus();
flag=false;
//return false;
}
if(contact=='Please enter your Contact Number' || contact=='Enter valid Contact Number' || contact=='')
{
str+="Please enter your Contact Number\n";
document.getElementById("ContactNo").focus();
flag=false;
//return false;
}
if(company=='Please enter your Company Name' || company=='Enter valid Company Name' || company=='')
{
str+="Please enter your Company Name\n";
document.getElementById("Company").focus();
flag=false;
//return false;
}
if(querytype=='Query Type' || querytype=='' || querytype=='Query Type')
{
str+="Please select QueryType\n";
document.getElementById("QueryType").focus();
flag=false;
//return false;
}
if(flag==false)
{
alert(str);
return false;
}
else
return true;
}
function name_check()
{
name=Trim(document.getElementById("Name").value) ;
if(name=='Please enter your Name' || name=='Please enter Alphabets only')
{
document.getElementById("Name").value ='';
return false;
}
return true;
}
function email_check()
{
email=Trim(document.getElementById("Email").value) ;
if(email=='Please enter your E-mail' || email=='Enter valid E-mail eg name@yahoo.com')
{
document.getElementById("Email").value ='';
return false;
}
return true;
}
function contact_check()
{
contact=Trim(document.getElementById("ContactNo").value) ;
if(contact=='Please enter your Contact Number' || contact=='Enter valid Contact Number')
{
document.getElementById("ContactNo").value ='';
return false;
}
return true;
}
function Company_check()
{
contact=Trim(document.getElementById("Company").value) ;
if(contact=='Please enter your Company Name' || contact=='Please Enter valid Company Name')
{
document.getElementById("Company").value ='';
return false;
}
return true;
}
//for errors
function name_error()
{
obj=document.getElementById("formId");
name_obj=Trim(obj.Name.value);
//alert(name_obj);
if(name_obj=='Name' || name_obj=='')
{
document.getElementById("Name").value="Please enter your Name" ;
return false;
}
else
{
var regexLetter = /^[a-zA-Z-/\s]+$/;
if(!regexLetter.test(name_obj))
{
document.getElementById("Name").value="Please enter Alphabets only";
return false;
}
}
return true;
}
function email_error()
{
obj=document.getElementById("formId");
email_obj=Trim(obj.Email.value);
//alert(name_obj);
if(email_obj=='E-mail' || email_obj=='')
{
document.getElementById("Email").value="Please enter your E-mail" ;
return false;
}
else
{
var regexLetter = /^[a-zA-Z]+[a-zA-Z0-9._-]*\@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/;
if(!regexLetter.test(email_obj))
{
document.getElementById("Email").value="Enter valid E-mail eg name@yahoo.com";
return false;
}
}
return true;
}
function contact_error()
{
obj=document.getElementById("formId");
contact_obj=Trim(obj.ContactNo.value);
//alert(name_obj);
if(contact_obj=='Contact' || contact_obj=='')
{
document.getElementById("ContactNo").value="Please enter your Contact Number" ;
return false;
}
else
{
var regexLetter =/^\d{10}\d*$/;
if(!regexLetter.test(contact_obj))
{
document.getElementById("ContactNo").value="Enter valid Contact Number";
return false;
}
}
return true;
}
function Company_error()
{
obj=document.getElementById("formId");
company_obj=Trim(obj.Company.value);
//alert(name_obj);
if(company_obj=='Company' || company_obj=='')
{
document.getElementById("Company").value="Please enter your Company Name" ;
return false;
}
else
{
var regexLetter = /^[0-9a-zA-Z-/\s]+$/;
if(!regexLetter.test(company_obj))
{
document.getElementById("Company").value="Please Enter valid Company Name";
return false;
}
}
return true;
}
</script>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" id="formId" enctype="multipart/form-data" onsubmit="return Validateform();">
<div class="login_lft">
<div class="login_txt">Name<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Name" type="text" class="field" id="Name" maxlength="30" value='Please enter your Name' onblur="return name_error();" onclick="return name_check();" onfocus="return name_check();" tabindex="1" maxlength="50"/>
</label>
</div>
<div class="login_txt">E-mail Id<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Email" type="text" class="field" id="Email" value="Please enter your E-mail" onblur="return email_error();" onclick="return email_check();" onfocus="return email_check();" tabindex="3" maxlength="100"/>
</label>
</div>
<div class="login_field">
<label></label>
</div>
<div class="login_txt">Query Type<span class="red">*</span></div>
<div class="login_field">
<label>
<select name="QueryType" class="field" id="QueryType" tabindex="5" >
<option value="Query Type" selected="selected">Query Type</option>
<option value="Application Development & Design">Application Development & Design</option>
<option value="AMC">AMC</option>
<option value="Application Migration">Application Migration</option>
<option value="Data Centre">Data Centre</option>
<option value="FLMS Demo">FLMS Demo</option>
<option value="Mobile Application">Mobile Application</option>
<option value="Network">Network</option>
<option value="Remote infrastrucher Management">Remote infrastrucher Management</option>
<option value="Testing">Testing</option>
<option value="TIMS Demo">TIMS Demo</option>
<option value="Other Query">Other Query</option>
</select>
</label>
</div>
</div>
<div class="login_rgt">
<!--<div class="login_txt">Subject<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Subject" type="text" class="field" id="Subject" value="please enter Subject" onblur="return Subject_error();" onclick="return Subject_check();" onfocus="return Subject_check();" maxlength="50"/>
</label>
</div>-->
<div class="login_txt">Company Name<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="Company" type="text" class="field" id="Company" value="Please enter your Company Name" onblur="return Company_error();" onclick="return Company_check();" onfocus="return Company_check();" tabindex="2" maxlength="200"/>
</label>
</div>
<div class="login_txt">Contact Number<span class="red">*</span></div>
<div class="login_field">
<label>
<input name="ContactNo" type="text" class="field" id="ContactNo" maxlength="11" value="Please enter your Contact Number" onblur="return contact_error();" onclick="return contact_check();" onfocus="return contact_check();" tabindex="4" />
</label>
</div>
<!-- <div class="login_txt">Website URL</div>
<div class="login_field">
<label>
<input name="WebsiteURL" type="text" class="field" id="WebsiteURL" />
</label>
</div>-->
<div class="login_txt">Attach File</div>
<div class="login_field">
<label>
<input type="file" name="ContactFile" id="ContactFile" tabindex="6" />
</label>
</div>
<div class="login_field"></div>
</div>
<div class="clear"></div>
<div class="div_adjust">
</div>
<div class="div_adjust">
<div class="login_txt">Message<br /></div>
<label>
<textarea name="Description" class="field3" id="Description" cols="45" rows="5" tabindex="7" maxlength="100"></textarea>
</label>
<div class="clear"></div>
</div><br />
<div>
<table width="60%" border="0">
<tr>
<td><input name="button" type="submit" id="button" value="Submit" class="input_button" tabindex="8" /></td>
<td>Fields marked with <span class="red2"> * </span> are mandatory.</td>
</tr>
</table>
</div>
</form>
</div>
</div>
<?php } ?>
No comments:
Post a Comment
Thank you for your Comment....