// JavaScript Document
function validateForm()
{
//	alert("shailendra.....");

	if(name() && email() && country() && phone() && comment())
	{
		document.frm1.submit();
	}
		return false;
		
}
function name() 
{
//	alert("shailendra.....");
	var str = document.frm1.name.value;
	
	if (str =="Enter Name")
	{
		alert("\nThe Name field is blank .\n\nPlease re-enter your Name");
		document.frm1.name.focus();		
		return false;
	}

	if( (str.substring(0,1)<"a" || str.substring(0,1)>"z") && (str.substring(0,1)<"A" || str.substring(0,1)>"Z"))
	{
		alert("The Name should begin with an alphabetic character.");
		document.frm1.name.select();
		document.frm1.name.focus();
		return false;
	}

	for (var i = 1; i < str.length; i++) 
	{
		var ch = str.substring(i, i + 1);
		if ( ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) &&(ch == '')) 
		{
			alert("\nThe Name field  accepts only letters.\n\nPlease re-enter your Name.");
			document.frm1.name.select();
			document.frm1.name.focus();
			return false;
		}

	}

	return true;

}

//Email

function email()

{

var str = document.frm1.email.value;

var str1 = document.frm1.email.value.length;

if(str == "")

	{

		alert("\nThe Email field is blank .\n\nPlease re-enter your Email id.")

		document.frm1.email.focus();

		return false;

	}

if (str.indexOf("@")== -1 || str.indexOf(".")== -1)

{

alert("Please enter the correct E-mail ID");

document.frm1.email.select();

document.frm1.email.focus();

return false;

}

if((str.substring(0,1) == "@" || str.substring(0,1)== ".") || str.substring(0,1)=="-" || str.substring(0,1)=="_")

	{

		alert("The Email ID can not begin with @ or . or - or _ ");

		document.frm1.email.select();

		document.frm1.email.focus();

		return false;

	}

if ((str.substring(str1-1,str1)=="@" || str.substring(str1-1,str1)=="."))

{

		alert("The email ID can not end with @ or . ");

		document.frm1.email.select();

		document.frm1.email.focus();

		return false;

}

var index1 = str.indexOf("@");
var index2 = str.indexOf(".");
var index3=str.indexOf("-");
var index4=str.indexOf("_");
if(str.substring(index1+1,index1+2) =="."){
alert(". can not come immidately after @");
document.frm1.email.select();
document.frm1.email.focus();
return false;
}
if ( ( index3==index1+1) || ( index4==index1+1))
{
alert("please enter the correct email ID as no two special chars can come in sequence");
document.frm1.email.select();
document.frm1.email.focus();
return false;
}
for (var i = 0; i < str.length; i++){
		var ch = str.substring(i, i + 1);
		if ( ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && (ch < "0" || "9" < ch) && (ch != '_') && ch !='-' && ch !='@' && ch !='.')
		{
			alert("\nThe email field  accepts letters,numbers & underscore.\n\nPlease re-enter your email id Name.");
			document.frm1.email.select();
			document.frm1.email.focus();
			return false;
		}
	}
	return true;
}
function country(){
//alert("shailendra....");
//alert(document.frm1.country.value);
if(document.frm1.country.value==""){
 alert("Select country name");
 document.frm1.country.focus();
	return false;
	}
	else return true; 
}
function countrycode(){
var str = document.frm1.countrycode.value;
if ( isNaN(str)){ 
alert("Please enter the numeric value in Country code Number field");
document.frm1.countrycode.select();
document.frm1.countrycode.focus();
return false;
}
if (str == ""){
		alert("\nThe Country code Number field is blank .\n\nPlease re-enter your Country code Number.")
		document.frm1.countrycode.focus();
		return false;
	}
	if((str.substring(0,1)<"0" || str.substring(0,1)>"9")){
		alert("The Work Country code should begin with an numeric character.");
		document.frm1.countrycode.focus();
		return false;
		}
		return true; 
}
function areacode(){
var str = document.frm1.areacode.value;
if ( isNaN(str)){ 
alert("Please enter the numeric value in Area code Number field");
document.frm1.areacode.select();
document.frm1.areacode.focus();
return false;
}
if (str == ""){
		alert("\nThe Area code Number field is blank .\n\nPlease re-enter your Area code Number.")
		document.frm1.areacode.focus();
		return false;
	}
	if((str.substring(0,1)<"0" || str.substring(0,1)>"9")){
		alert("The Work Area code should begin with an numeric character.");
		document.frm1.areacode.focus();
		return false;
		}
		return true; 
}
function phone(){
var str = document.frm1.phone.value;
if ( isNaN(str)){ 
alert("Please enter the numeric value in Phone or Mobile Number field");
document.frm1.phone.select();
document.frm1.phone.focus();
return false;
}
if (str == ""){
		alert("\nThe Phone or Mobile Number field is blank .\n\nPlease re-enter your Phone or Mobile Number.")
		document.frm1.phone.focus();
		return false;
	}
	if((str.substring(0,1)<"0" || str.substring(0,1)>"9")){
		alert("The Work phone should begin with an numeric character.");
		document.frm1.phone.focus();
		return false;
		}
		return true; 
}
function dd(){
if(document.frm1.dd.value=="")
{
  alert("Select Date ");
  document.frm1.dd.focus();
  return false;
	}
	else return true; 
}
function mm(){
if(document.frm1.mm.value=="")
{
 alert("Select Month ");
 document.frm1.mm.focus();
 return false;
	}
	else return true; 
}
function yyyy(){
if(document.frm1.yyyy.value=="")
{
 alert("Select Year ");
 document.frm1.yyyy.focus();
 return false;
	}
	else return true; 
}
function adult(){
var str = document.frm1.adult.value;
if ( isNaN(str)){ 
alert("Please enter the numeric value in Adult Number field");
document.frm1.adult.select();
document.frm1.adult.focus();
return false;
}
if (str == ""){
		alert("\nThe Adult Number field is blank .\n\nPlease re-enter your Adult Number.")
		document.frm1.adult.focus();
		return false;
	}
	if((str.substring(0,1)<"0" || str.substring(0,1)>"9")){
		alert("The Work Adult should begin with an numeric character.");
		document.frm1.adult.focus();
		return false;
		}
		return true; 
}

function children(){
var str = document.frm1.children.value;
if ( isNaN(str)){ 
alert("Please enter the numeric value in Adult Number field");
document.frm1.children.select();
document.frm1.children.focus();
return false;
}
if (str == ""){
		alert("\nThe Children Number field is blank .\n\nPlease re-enter your Children Number.")
		document.frm1.children.focus();
		return false;
	}
	if((str.substring(0,1)<"0" || str.substring(0,1)>"9")){
		alert("The Work Children should begin with an numeric character.");
		document.frm1.children.focus();
		return false;
		}
		return true; 
}
function dayinhand(){
var str = document.frm1.dayinhand.value;
if ( isNaN(str)){ 
alert("Please enter the numeric value in Day in hand Number field");
document.frm1.dayinhand.select();
document.frm1.dayinhand.focus();
return false;
}
if (str == ""){
		alert("\nThe Day in hand Number field is blank .\n\nPlease re-enter your Day in hand Number.")
		document.frm1.dayinhand.focus();
		return false;
	}
	if((str.substring(0,1)<"0" || str.substring(0,1)>"9")){
		alert("The Work Day in hand should begin with an numeric character.");
		document.frm1.dayinhand.focus();
		return false;
		}
		return true; 
}
function comment(){
if(document.frm1.comment.value=="")
{
 alert("Please enter Your Requirements");
 document.frm1.comment.focus();
   return false;
	}
	else return true; 
}


