function validchars(fldname,sts,msg)
	{		
		var fldlen = document.getElementById(fldname).value.length;
		var chksts = sts;
		if(chksts == "genchars")
		{
			var ichars = "@$%^*+=\\{}|<>";
		}
		else if(chksts == "mailchars")
		{
			var ichars = "!$#%^&*()+=-[]\\\':,/{}|\":<>?";
		}
		
		else if(chksts == "phonechars")
		{
			var ichars = "!@$#%^&*()+=[]\\\':,.{}|\":<>?abcdeghijklmnopqrstuvwxyzABCDEGHIJKLMNOPQRSTUVWXYZ";
		}
		
	
		for(var i=0;i < document.getElementById(fldname).value.length;i++)
		{
			if(ichars.indexOf(document.getElementById(fldname).value.charAt(i)) != -1)
			{
				alert(msg + " contain invalid characters");
				document.getElementById(fldname).focus();
				return false;
			}	
		}
	}
	
	
	
function chkspc(cntrl)
{
	var spchars;
	var spcsts;
	var len = document.getElementById(cntrl).value.length - 1;
	spchars = " ";
	spcsts = "f"; //false
	if(spchars.indexOf(document.getElementById(cntrl).value.charAt(0)) != -1)
	{
		spcsts = "t"; //true
		alert("Spaces are not allowed in the first place");				
	}
	else if(spchars.indexOf(document.getElementById(cntrl).value.charAt(len)) != -1)
	{
		spcsts = "t"; //true
		alert("Spaces are not allowed in the last place");								
	}
	if(spcsts == "t")
	{
		document.getElementById(cntrl).focus();
		return false;				
	}
}



var reEmail = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;

function echeck(strValue) 

				{

				  return reEmail.test(strValue);

				}
function validata()

				{

					
					
				
					
					if(document.myform.name.value == "")

					{

						alert("Name can't be blank");

						document.myform.name.focus();

						return false

					}
					
					if(document.myform.country.value == "")

					{

						alert("Country can't be blank");

						document.myform.country.focus();

						return false

					}
					
					if(document.myform.city.value == "")

					{

						alert("State/City can't be blank");

						document.myform.city.focus();

						return false

					}
					
					
				if(document.myform.mobile.value == "")

					{

						alert("Mobile can't be blank");

						document.myform.mobile.focus();

						return false

					}
				else if(document.myform.mobile.value != "")
					 if(chkspc("mobile")==false || validchars("mobile","phonechars","Mobile")==false)

						{

							return false

						}
					
					if(document.myform.mail.value == "")

					{

						alert("Email ID can't be blank");

						document.myform.mail.focus();

						return false

					}
					
				else 
				{
				  if(document.myform.mail.value != "")
						if(chkspc("mail")==false || validchars("mail","mailchars","E-Mail")==false)

						{

							return false

						}
					
				if(echeck(document.myform.mail.value)==false)

					{		

						alert("Enter a valid email id");

						document.myform.mail.focus();

						return false

					}
				}
			   
				
				if(document.myform.msg.value == "")

					{

						alert("Message can't be blank");

						document.myform.msg.focus();

						return false

					}
										
				return true
				
	}		

