// JavaScript Document
function validate(frm)
{
	 if(frm.fname.value=='')
	 {
	  alert('Please Enter your First Name');
	  frm.fname.focus();
	  return false;
	 }
	 
	 if(frm.lname.value=='')
	 {
	  alert('Please Enter your Last Name');
	  frm.lname.focus();
	  return false;
	 }
	 
	if(frm.phoneno.value=='')
	 {
	  alert('Please Enter your Phone No.');
	  frm.phoneno.focus();
	  return false;
	 }
	 if(frm.phoneno.value!="")
	{
		if(!checknumber(frm.phoneno.value))
		{
			alert("Please specify a valid phone no. !!");
			frm.phoneno.value="";
			frm.phoneno.focus();
			return false;
		}
	}
	
	var emailID=frm.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
		}
		 if(frm.comment.value=='')
	 {
	  alert('Please Enter your Comments');
	  frm.comment.focus();
	  return false;
	 }
	 if(frm.Name.value=='')
	 {
	  alert('Please Enter your Name');
	  frm.Name.focus();
	  return false;
	 }
	 
	return true;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID,Please Enter your valid Email ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID,Please Enter your valid Email ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID,Please Enter your valid Email ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID,Please Enter your valid Email ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID,Please Enter your valid Email ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID,Please Enter your valid Email ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID,Please Enter your valid Email ID")
		    return false
		 }

 		 return true			
}
function checknumber(value)
  	{ 
     for(j=0;j<value.length;j++)
     {c=value.charAt(j);
        if((c!='0')&& (c!='1')&&(c!='2')&&(c!='3')&&(c!='4')&&(c!='5')&&(c!='6')&&(c!='7')&&(c!='8')&&(c!='9'))
        return false;
     }
     return true;
	}

