var flag="true";
var emailRegEx=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$///E-Mail ID EX KISHORE@YAHOO.COM
var  PhoneRegEx =/^\d{11}$/;                                      //PHONE NUMBER SHOLD HAVE ELEVEN DIGITS
var  MbRegEx =/^\d{10}$/;  
var  MbRegEx1 =/^\d{7}$/;  
var  MbRegEx2 =/^\d{8}$/;  
var  MbRegEx3 =/^\d{9}$/;  
var  MbRegEx4 =/^\d{12}$/;  
var nameRegEx = /^(\d)+([a-zA-Z0-9])*/;                           // Name cant Start with Numbers
var specialChar1 = /^([a-zA-Z\s0-9_\.\-])*[\!\@\#\$\%\^\&\*\(\)\/\>\<\,\.\`\~\+\=\'\"\:\;]+([a-zA-Z0-9_\.\-\s\W])*$/;//check for 
var Blank= /^(\s)+([\sa-zA-Z0-9_\.\-\W])*$/;                       //IF AT START THERE IS SPACE
var specialChar = /^([a-zA-Z\s0-9_\.\-])*[\!\@\#\$\%\^\&\*\(\)\/\>\<\,\`\~\+\=\'\"\:\;]+([a-zA-Z0-9_\.\-\s\W])*$/;//check for 

function is_mail(id)
{

	var o=document.getElementById(id);
	var sub=document.getElementById("form");
	var obj=document.getElementById("div");
	mailname=new String(o.value);
	if(mailname.length<5)
	{
		o.value="";
		flag="1";
		o.style.backgroundColor="yellow";
	}
	else 
	{
		if(mailname.match(emailRegEx))
		{ 
			o.style.backgroundColor="white";
		}
		else
		{
			o.value="";
			flag="1";
			o.style.backgroundColor="yellow";
		}
	}
}

function is_phone(id)
{
	var obj=document.getElementById(id);
	var Mystring = new String(obj.value);
	
	if(Mystring==0)
	{
		flag="1";
		obj.value="";
		obj.style.backgroundColor="yellow";
	}
	
	if(Mystring.match(PhoneRegEx)||Mystring.match(MbRegEx)||Mystring.match(MbRegEx1)||Mystring.match(MbRegEx2)||Mystring.match(MbRegEx3)||Mystring.match(MbRegEx4))
	{
		obj.style.backgroundColor="white"; 
	}
	
	else if(Mystring.length<1)
	{
		flag="1";
		obj.value="";
		obj.style.backgroundColor="yellow";
		
	}
	else
	{
		flag="1";
		obj.value="";
		obj.style.backgroundColor="yellow";
	}
}


function is_name(id)
{
     var obj=document.getElementById(id);
     var Mystring=obj.value ;
	 if(Mystring.length<2)
     {
       
		flag="1";
		obj.value="";
		obj.style.backgroundColor="yellow";
     }
     else if(Mystring.match(Blank))
     {
       
		flag="1";
		obj.value="";
		obj.style.backgroundColor="yellow";

     }
     else if(Mystring.match(nameRegEx))
     {
       
		flag="1";
		obj.value="";
		obj.style.backgroundColor="white";
     }
     else if(Mystring.match(specialChar1))
     {
       
	   flag="1";
       obj.value="";

     }
	 else
	 {
		 obj.style.backgroundColor="white";
		
	 }

}

var object;
function isFlag(element,form,date,name,phone,email,quali)
{
	object=element;
	var formid = document.getElementById(form);
	flag="true";
	is_name(name);
	is_phone(phone);
	is_mail(email);
    if(flag!="true")
    {
	  alert("PLEASE INSERT INFORMATION PROPERLY!!!");
	  object.disabled=false;
    }
}