// JavaScript Document

function emailcheck(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")
return false
}



if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(at,(lat+1))!=-1){

alert("Invalid E-mail ID")

return false

}



if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(dot,(lat+2))==-1){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(" ")!=-1){

alert("Invalid E-mail ID")

return false

}
return true 
}

function validate()
{
 var frm=document.personal;
 //firstname lastname phonenumber email realtorsname realtorsphone propertyaddress	
if(frm.firstname.value=='')
{
	alert("please enter first name");
	frm.firstname.focus();
	return false
}
if(frm.lastname.value=='')
{
	alert("please enter last name");
	frm.lastname.focus();
	return false
}

if(frm.phonenumber.value=='')
{
	alert("please enter phonenumber");
	frm.phonenumber.focus();
	return false
}

if(frm.email.value=='')
{
	alert("please enter email");
	frm.email.focus();
	return false
}

var emailID=frm.email;

	if ((emailID.value==null)||(emailID.value==""))

	{

		alert("Please Enter your Email ID")

		emailID.focus()

		return false;

	}

	if (emailcheck(emailID.value)==false)

	{

		emailID.value=""

		emailID.focus()

		return false;

	}	

if(frm.realtorsname.value=='')
{
	alert("please enter realtor name");
	frm.realtorsname.focus();
	return false
}

if(frm.realtorsphone.value=='')
{
	alert("please enter realtor phone");
	frm.realtorsphone.focus();
	return false
}

if(frm.propertyaddress.value=='')
{
	alert("please enter property address");
	frm.propertyaddress.focus();
	return false
}
return true;
}

function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
if(unicode==9 || unicode==46 ||unicode==127)
{
return true;
}
if (unicode!=8){ 
if (unicode<48||unicode>57) 
return false 
}

return true;

}


