﻿function validate(){
if(document.forms[0].name.value=="")
{alert("Enter your name"); return false;}
if(document.forms[0].email.value=="")
{alert("Enter your email"); return false;}
if(document.forms[0].email.value!="")
{value=isMail(document.forms[0].email.value);
if(!value){alert("Invalid Email");return false;}}
if(document.forms[0].message.value=="")
{alert("Enter your message"); return false;}
}
String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}
function isMail(msg)
    {
 	 check=1;
    counter=0;
	for(var i=0;i<msg.length;i++)
         {
		if(msg.charAt(i)=='@')
		 counter=counter+1;
         }
	if(counter>1)
	  check=0;
	if((t=msg.indexOf("@"))<0)
 	  check=0;
	 if((t=msg.indexOf("."))<0)
 	  check=0;
	if(check==1)
	return true;
        else
        return false;
    }
