
function chk_string( str, req, min, max )// Checking the lent of the text box
{
	if( str.length == 0 && !req )
		return 0;
	if( str.length < min || str.length > max )
		return 1;
	return 0;
}


function chk_email( str, req )
{
	var email_RegEx = /^\w+([-.]\w+)*\@\w+([-.]\w+)*\.\w+$/;
	if( str.length == 0 && !req )
	    return 0;
	var found = email_RegEx.test( str );
	if( found == false )
	    return 1;
	return 0;
}
function datavalidation()
{	
		
	if( chk_string( document.form.name.value, 1, 2, 200 ) )
	{
		alert("Name is not specified");
		document.form.name.focus();
		return false;
	}	
	
	 if( chk_email( document.form.emailid.value, 1, 2, 200 ) )
	{
		alert("Email address invalid or not specified");
		document.form.emailid.focus();
		return false;
	} 
	


	if( chk_string( document.form.subject.value, 1, 2, 200 ) )
	{
		alert("Subject is not specified");
		document.form.subject.focus();
		return false;
	}	
	
	
	if( chk_string( document.form.message.value, 1, 2, 2000 ) )
	{
		alert("Message is not specified");
		document.form.message.focus();
		return false;
	}	


}
