
function onSubmit()
{
	var val = trim(document.getElementById("txt_name").value);
	var msg = "";
	if(val == "")
	{
		msg = "Please provide magazine name.";
		document.getElementById("txt_name").focus();
		alert(msg);
		return false;
	}
	val = document.getElementById("ddl_category").selectedIndex;
	if(val == 0)
	{
		msg = "Please select category.";
		document.getElementById("ddl_category").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_pname").value);
	if(val == "")
	{
		msg = "Please provide publisher's name.";
		document.getElementById("txt_pname").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_issn").value);
	if(val == "")
	{
		msg = "Please provide ISSN.";
		document.getElementById("txt_issn").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_address").value);
	if(val == "")
	{
		msg = "Please provide address.";
		document.getElementById("txt_address").focus();
		alert(msg);
		return false;
	}
	val = document.getElementById("ddl_country").selectedIndex;
	if(val == 0)
	{
		msg = "Please select country.";
		document.getElementById("ddl_country").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_email").value);
	if(val == "")
	{
		msg = "Please provide Email Id.";
		document.getElementById("txt_email").focus();
		alert(msg);
		return false;
	}
	else
	{
		if(checkEmail(val) != true)
		{
			msg = "Invalid Email Id.";
			document.getElementById("txt_email").focus();
			alert(msg);
			return false;
		}
	}
	val = trim(document.getElementById("txt_phcountry").value);
	if(val == "")
	{
		msg = "Please provide country code of phone no.";
		document.getElementById("txt_phcountry").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_pharea").value);
	if(val == "")
	{
		msg = "Please provide area code of phone no.";
		document.getElementById("txt_pharea").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_phno").value);
	if(val == "")
	{
		msg = "Please provide phone no.";
		document.getElementById("txt_phno").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_contactperson").value);
	if(val == "")
	{
		msg = "Please provide contact person name.";
		document.getElementById("txt_contactperson").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("ddl_frequency").value);
	if(val == "Select Frequency")
	{
		msg = "Please select frequency of magazine.";
		document.getElementById("ddl_frequency").focus();
		alert(msg);
		return false;
	}
	val = trim(document.getElementById("txt_language").value);
	if(val == "")
	{
		msg = "Please provide language of magazine.";
		document.getElementById("txt_language").focus();
		alert(msg);
		return false;
	}
	if(val == "Others")
	{
		val = trim(document.getElementById("txt_fopublishing").value);
		if(val == "")
		{
			msg = "Please specify frequency of publishing .";
			document.getElementById("txt_fopublishing").focus();
			alert(msg);
			return false;
		}
	}
	
	
	return true;
	
}

function magazinecontant()
{
	var val = trim(document.getElementById("txt_name").value);
	if(val == "")
	{
		alert("Please provide name");
		document.getElementById("txt_name").focus();
		return false;
	}
	val = trim(document.getElementById("txt_organizationname").value);
	if(val == "")
	{
		alert("Please provide organization name");
		document.getElementById("txt_organizationname").focus();
		return false;
	}
	
	val = document.getElementById("ddl_country").selectedIndex;
	if(val == 0)
	{
		alert("Please select country");
		document.getElementById("ddl_country").focus();
		return false;
	}
	
	val = trim(document.getElementById("txt_phno").value);
	var val1 = trim(document.getElementById("txt_phcountry").value);
	var val2 = trim(document.getElementById("txt_pharea").value);
	
	if(val == "" && val1 == "" && val2 == "")
	{
		alert("Please provide phone no.");
		document.getElementById("txt_phcountry").focus();
		return false;
	}
	
	if(val1 == "")
	{
		alert("Please provide country code of phone no.");
		document.getElementById("txt_phcountry").focus();
		return false;
	}
	
	if(val2 == "")
	{
		alert("Please provide area code of phone no.");
		document.getElementById("txt_pharea").focus();
		return false;
	}
	
	if(val == "")
	{
		alert("Please provide phone no.");
		document.getElementById("txt_phno").focus();
		return false;
	}
	
	val = trim(document.getElementById("txt_email").value);
	if(val == "")
	{
		alert("Please provide email id");
		document.getElementById("txt_email").focus();
		return false;
	}
	else
	{
		if(checkEmail(val) == false)
		{
			alert("Invalid Email Id");
			document.getElementById("txt_email").focus();
			return false;
		}
	}
	if(trim(document.getElementById('txt_inquiry').value) != "")
	{
		if(trim(document.getElementById('txt_inquiry').value).search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid inquiry. No script tags / HTML tags and Scripting is allowed in inquiry.");
			document.getElementById('txt_inquiry').focus();
			return false;
		}
	}
	return true;
}

function validation()
{
	
	var name=document.getElementById('txtname');
	var country=document.getElementById('ddlcountry');
	var email=document.getElementById('txtmail');
	var phno=document.getElementById('txt_phno');
	var fno=document.getElementById('txt_fno');
	var txtcompany=document.getElementById('txtcompany');
	
	if (trim(name.value)=="")
	{
		alert("Please Enter Name.")
		name.focus()
		return false;
	}
	if (trim(txtcompany.value)=="")
	{
		alert("Please Enter Your Company Name.")
		txtcompany.focus()
		return false;
	}
	
	if (trim(email.value)=="")
	{
		alert("Please Enter EmailId.")
		email.focus()
		return false;
	}	
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(trim(email.value))) 
	{
		alert("Please provide a valid EmailId");
		email.focus();
		return false;
	}
	if(trim(phno.value) != "")
	{
		if(trim(document.getElementById('txt_ccodephno').value) == "")
		{
			alert("Please Enter country code of phone no.");
			document.getElementById('txt_ccodephno').focus();
			return false;
		}
		if(trim(document.getElementById('txt_acodephno').value) == "")
		{
			alert("Please Enter area code of phone no.");
			document.getElementById('txt_acodephno').focus();
			return false;
		}
	}
	if(trim(document.getElementById('txt_ccodephno').value) != "")
	{
		if((trim(document.getElementById('txt_acodephno').value) == "") || trim(phno.value) == "")
		{
			alert("Please Enter proper phone no.")
			return false;
		}
	}
	else
	{
		if(trim(document.getElementById('txt_acodephno').value) != "")
		{
			if((trim(document.getElementById('txt_ccodephno').value) == "") || trim(phno.value) == "")
			{
				alert("Please Enter proper phone no.")
				return false;
			}
		}
	}
	
	if(trim(document.getElementById('magazinename').value) == "")
	{
		alert("Please Enter MagazineName.");
		document.getElementById('magazinename').focus();
		return false;
	}
//	return true;	
	if(trim(document.getElementById('advertize').value) == "")
	{
		alert("Please Enter What You Want to advertise.");
		document.getElementById('advertize').focus();
		return false;
	}
	else
	{
		if(trim(document.getElementById('advertize').value).search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid advertise. No script tags / HTML tags and Scripting is allowed in advertise.");
			document.getElementById('advertize').focus();
			return false;
		}
	}
	return true;
}

function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ValidNum(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if(asc > 47 && asc < 58)
	{
		return true;
	}
	return false;
}

function ValidPhone(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if((asc > 47 && asc<58) || asc == 43)
		return true;
	else 
		return false;
}

function checkEmail(email) 
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
	{
		return false;
	}
	return true;
	
}

function contactValidation()
{

	var name=document.getElementById('txtname');
	var country=document.getElementById('ddlcountry');
	var email=document.getElementById('txtmail');
	var phno=document.getElementById('txt_phno');
	var fno=document.getElementById('txt_fno');
	var txtcompany=document.getElementById('txtcompany');
	if (trim(name.value)=="")
	{
		alert("Please Enter Name.")
		name.focus()
		return false;
	}
	if (trim(txtcompany.value)=="")
	{
		alert("Please Enter Your Company Name.")
		txtcompany.focus()
		return false;
	}
	if (trim(email.value)=="")
	{
		alert("Please Enter EmailId.")
		email.focus()
		return false;
	}	
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(trim(email.value))) 
	{
		alert("Please provide a valid EmailId");
		email.focus();
		return false;
	}
	if(trim(phno.value) != "")
	{
		if(trim(document.getElementById('txt_ccodephno').value) == "")
		{
			alert("Please Enter country code of phone no.");
			document.getElementById('txt_ccodephno').focus();
			return false;
		}
		if(trim(document.getElementById('txt_acodephno').value) == "")
		{
			alert("Please Enter area code of phone no.");
			document.getElementById('txt_acodephno').focus();
			return false;
		}
	}
	if(trim(document.getElementById('txt_ccodephno').value) != "")
	{
		if((trim(document.getElementById('txt_acodephno').value) == "") || trim(phno.value) == "")
		{
			alert("Please Enter proper phone no.")
			return false;
		}
	}
	else
	{
		if(trim(document.getElementById('txt_acodephno').value) != "")
		{
			if((trim(document.getElementById('txt_ccodephno').value) == "") || trim(phno.value) == "")
			{
				alert("Please Enter proper phone no.")
				return false;
			}
		}
	}
	if(trim(fno.value) != "")
	{
		if(trim(document.getElementById('txt_ccodefno').value) == "")
		{
			alert("Please Enter country code of fax no.")
			document.getElementById('txt_ccodefno').focus();
			return false;
		}
		if(trim(document.getElementById('txt_acodefno').value) == "")
		{
			alert("Please Enter area code of fax no.")
			document.getElementById('txt_acodefno').focus();
			return false;
		}
	}
	if(trim(document.getElementById('txt_ccodefno').value) != "")
	{
		if((trim(document.getElementById('txt_acodefno').value) == "") || trim(fno.value) == "")
		{
			alert("Please Enter proper fax no.")
			return false;
		}
	}
	else
	{
		if(trim(document.getElementById('txt_acodefno').value) != "")
		{
			if((trim(document.getElementById('txt_ccodefno').value) == "") || trim(fno.value) == "")
			{
				alert("Please Enter proper fax no.")
				return false;
			}
		}
	}
	if(trim(document.getElementById('txtinq').value) == "")
	{
		alert("Please Enter inquiry.");
		document.getElementById('txtinq').focus();
		return false;
	}
	else
	{
		if(trim(document.getElementById('txtinq').value).search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid Inquiry. No script tags / HTML tags and Scripting is allowed in Inquiry.");
			document.getElementById('txtinq').focus();
			return false;
		}
	}
	return true;	
}

function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ValidNum(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if(asc > 47 && asc < 58)
	{
		return true;
	}
	return false;
}

function ValidPhone(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if((asc > 47 && asc<58) || asc == 43)
		return true;
	else 
		return false;
}

function checkEmail(email) 
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
	{
		return false;
	}
	return true;
}

function validation1()
{
	var name=document.getElementById('txtname');
	var country=document.getElementById('ddlcountry');
	var email=document.getElementById('txtmail');
	var phno=document.getElementById('txt_phno');
	var fno=document.getElementById('txt_fno');
	var txtcompany=document.getElementById('txtcompany');
	if (trim(name.value)=="")
	{
		alert("Please Enter Name.")
		name.focus()
		return false;
	}
	if (trim(txtcompany.value)=="")
	{
		alert("Please Enter Your Company Name.")
		txtcompany.focus()
		return false;
	}
	if (trim(email.value)=="")
	{
		alert("Please Enter EmailId.")
		email.focus()
		return false;
	}	
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(trim(email.value))) 
	{
		alert("Please provide a valid EmailId");
		email.focus();
		return false;
	}
	if(trim(phno.value) != "")
	{
		if(trim(document.getElementById('txt_ccodephno').value) == "")
		{
			alert("Please Enter country code of phone no.");
			document.getElementById('txt_ccodephno').focus();
			return false;
		}
		if(trim(document.getElementById('txt_acodephno').value) == "")
		{
			alert("Please Enter area code of phone no.");
			document.getElementById('txt_acodephno').focus();
			return false;
		}
	}
	if(trim(document.getElementById('txt_ccodephno').value) != "")
	{
		if((trim(document.getElementById('txt_acodephno').value) == "") || trim(phno.value) == "")
		{
			alert("Please Enter proper phone no.")
			return false;
		}
	}
	else
	{
		if(trim(document.getElementById('txt_acodephno').value) != "")
		{
			if((trim(document.getElementById('txt_ccodephno').value) == "") || trim(phno.value) == "")
			{
				alert("Please Enter proper phone no.")
				return false;
			}
		}
	}
	
	if(trim(document.getElementById('comments').value) == "")
	{
		alert("Please Enter Comments.");
		document.getElementById('comments').focus();
		return false;
	}
	else
	{
		if(trim(document.getElementById('comments').value).search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid comment. No script tags / HTML tags and Scripting is allowed in comments.");
			document.getElementById('comments').focus();
			return false;
		}
	}
	return true;
}

function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ValidNum(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if(asc > 47 && asc < 58)
	{
		return true;
	}
	return false;
}

function ValidPhone(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if((asc > 47 && asc<58) || asc == 43)
		return true;
	else 
		return false;
}

function checkEmail(email) 
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
	{
		return false;
	}
	return true;
	
}

function samplevalidation()
{
	var name=document.getElementById('txtname');
	var country=document.getElementById('ddlcountry');
	var email=document.getElementById('txtmail');
	var phno=document.getElementById('txt_phno');
	var fno=document.getElementById('txt_fno');
	var txtcompany=document.getElementById('txtcompany');
	if (trim(name.value)=="")
	{
		alert("Please Enter Name.")
		name.focus()
		return false;
	}
	if (trim(txtcompany.value)=="")
	{
		alert("Please Enter Your Company Name.")
		txtcompany.focus()
		return false;
	}
	if (trim(email.value)=="")
	{
		alert("Please Enter EmailId.")
		email.focus()
		return false;
	}	
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(trim(email.value))) 
	{
		alert("Please provide a valid EmailId");
		email.focus();
		return false;
	}
	if(trim(phno.value) != "")
	{
		if(trim(document.getElementById('txt_ccodephno').value) == "")
		{
			alert("Please Enter country code of phone no.");
			document.getElementById('txt_ccodephno').focus();
			return false;
		}
		if(trim(document.getElementById('txt_acodephno').value) == "")
		{
			alert("Please Enter area code of phone no.");
			document.getElementById('txt_acodephno').focus();
			return false;
		}
	}
	if(trim(document.getElementById('txt_ccodephno').value) != "")
	{
		if((trim(document.getElementById('txt_acodephno').value) == "") || trim(phno.value) == "")
		{
			alert("Please Enter proper phone no.")
			return false;
		}
	}
	else
	{
		if(trim(document.getElementById('txt_acodephno').value) != "")
		{
			if((trim(document.getElementById('txt_ccodephno').value) == "") || trim(phno.value) == "")
			{
				alert("Please Enter proper phone no.")
				return false;
			}
		}
	}
	
	if(trim(document.getElementById('magazine').value) == "")
	{
		alert("Please Enter MagazineName.");
		document.getElementById('magazine').focus();
		return false;
	}
//	return true;	
	if(trim(document.getElementById('comments').value) == "")
	{
		alert("Please Enter Comments");
		document.getElementById('comments').focus();
		return false;
	}
	else
	{
		if(trim(document.getElementById('comments').value).search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid comment. No script tags / HTML tags and Scripting is allowed in comments.");
			document.getElementById('comments').focus();
			return false;
		}
	}
	return true;
}

function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ValidNum(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if(asc > 47 && asc < 58)
	{
		return true;
	}
	return false;
}

function ValidPhone(e)
{
	var asc = event.keyCode ? e.keyCode : e.which;
	if((asc > 47 && asc<58) || asc == 43)
		return true;
	else 
		return false;
}

function checkEmail(email) 
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
	{
		return false;
	}
	return true;
	
}


function sapceformagazine()
{
	var val = document.getElementById('txtname');
	if(trim(val.value) == "")
	{
		alert("Please enter name");
		val.focus();
		return false;
	}
	else
	{
		if(val.value.search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid name. No script tags / HTML tags and Scripting is allowed in name.");
			val.focus();
			return false;
		}
	}
	val = document.getElementById('txtmagazine');
	if(trim(val.value) == "")
	{
		alert("Please enter magazine name");
		val.focus();
		return false;
	}
	else
	{
		if(val.value.search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid magazine name. No script tags / HTML tags and Scripting is allowed in magazine name.");
			val.focus();
			return false;
		}
	}
	val = document.getElementById('txtmail');
	if(trim(val.value) == "")
	{
		alert("Please enter email");
		val.focus();
		return false;
	}
	else
	{
		if(val.value.search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid email. No script tags / HTML tags and Scripting is allowed in email.");
			val.focus();
			return false;
		}
	}
	if(checkEmail(val.value) == false)
	{
		alert("Please enter valid email");
		val.focus();
		return false;
	}
	
	val = document.getElementById('txt_ccodephno');
	if(trim(val.value) == "")
	{
		alert("Please enter country code of phone no.");
		val.focus();
		return false;
	}
	else
	{
		if(val.value.search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid country code. No script tags / HTML tags and Scripting is allowed in country code.");
			val.focus();
			return false;
		}
	}
	val = document.getElementById('txt_acodephno');
	if(trim(val.value) == "")
	{
		alert("Please enter area code of phone no.");
		val.focus();
		return false;
	}
	else
	{
		if(val.value.search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid area code. No script tags / HTML tags and Scripting is allowed in area code.");
			val.focus();
			return false;
		}
	}
	val = document.getElementById('txt_phno');
	if(trim(val.value) == "")
	{
		alert("Please enter phone no.");
		val.focus();
		return false;
	}
	else
	{
		if(val.value.search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid phone no. No script tags / HTML tags and Scripting is allowed in phone no.");
			val.focus();
			return false;
		}
	}
	val = document.getElementById('advertize');
	if(trim(val.value) == "")
	{
		alert("Please enter comments");
		val.focus();
		return false;
	}
	else
	{
		if(val.value.search(/<[^>]+>/) >= 0 )
		{
			alert("Please enter valid comments. No script tags / HTML tags and Scripting is allowed in comments.");
			val.focus();
			return false;
		}
	}
	
	return true;
}
