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-Za-z0-9]+([_.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*.([A-Za-z]){2,4}$/i;

function echeck(strValue) 

				{

				  return reEmail.test(strValue);

				}
function validata()

				{

					if(document.fm1.name.value == "")

					{

						alert("Name can't be blank");

						document.fm1.name.focus();

						return false

					}
			 	   
				
				if(document.fm1.phone.value == "")

					{

						alert("Phone number can't be blank");

						document.fm1.phone.focus();

						return false

					}
				
			    else if(document.fm1.phone.value != "")
						if(chkspc("phone")==false || validchars("phone","phonechars","Phone")==false)

						{

							return false

						}
						
						
				if(document.fm1.email.value == "")

					{

						alert("Email ID can't be blank");

						document.fm1.email.focus();

						return false

					}
					
				else 
				{
				  if(document.fm1.email.value != "")
						if(chkspc("email")==false || validchars("email","mailchars","Email")==false)

						{

							return false

						}
					
				if(echeck(document.fm1.email.value)==false)

					{		

						alert("Enter a valid email id");

						document.fm1.email.focus();

						return false

					}
				}	
				
				
				if(document.fm1.cmnt.value == "")

					{

						alert("Requirements can't be blank");

						document.fm1.cmnt.focus();

						return false

					}
					
				return true
				
	}
	
function signupvali()

				{

					if(document.fm1.name.value == "")

					{

						alert("Name can't be blank");

						document.fm1.name.focus();

						return false

					}
			   
				if(document.fm1.phone.value == "")

					{

						alert("Phone number can't be blank");

						document.fm1.phone.focus();

						return false

					}
				
			    else if(document.fm1.phone.value != "")
						if(chkspc("phone")==false || validchars("phone","phonechars","Phone")==false)

						{

							return false

						}				
						
				if(document.fm1.email.value == "")

					{

						alert("Email ID can't be blank");

						document.fm1.email.focus();

						return false

					}
					
				else 
				{
				  if(document.fm1.email.value != "")
						if(chkspc("email")==false || validchars("email","mailchars","Email")==false)

						{

							return false

						}
					
				if(echeck(document.fm1.email.value)==false)

					{		

						alert("Enter a valid email id");

						document.fm1.email.focus();

						return false

					}
				}		
						
				return true
				
	}		


