function isValidEmail(checkStr)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	var EmailValid = filter.test(checkStr);
	return (EmailValid);
}

function isValidZip(zip)
{
	var filter = /^[0-9]{5}$/;
	var zipValid = filter.test(zip);
	return zipValid;
}

function isValidPhone(hphone)
{
	var filter = /^[^a-zA-Z]*$/;
	var phoneValid = filter.test(hphone);
	return phoneValid;
}

function chForm()
{
	var fname = document.getElementById('first_name')
	var lname = document.getElementById('last_name');
	var hphone = document.getElementById('home_phone');
	var mail = document.getElementById('email');
	var paddress = document.getElementById('property_address');
	var zip = document.getElementById('property_zip');
	var city = document.getElementById('property_city');

	if ( fname.value == "" )
	{
		alert("Fill your First Name");
		fname.focus();
		return (false);
		exit();
	}

	if ( lname.value == "" )
	{
		alert("Enter your Last Name");
		lname.focus();
		return (false);
	}
	
	if ( mail.value == "" )
	{
		alert("Enter your Email.");
		mail.focus();
		return (false);
	}
	
	if (!isValidEmail(mail.value))
	{
    	alert("This is not valid email address! " + mail.value + " Fill email address again.");
	    mail.focus();
    	return (false);
	}

	if ( hphone.value == "" )
	{
		alert("Enter your Home Phone.");
		hphone.focus();
		return (false);
	}
	
	if ( !isValidPhone(hphone.value) )
	{
		alert("This is not valid phone nuber! >> " + hphone.value + " << Fill it again please.");
		hphone.focus();
		return (false);
	}

	if ( paddress.value == "" )
	{
		alert("Enter property address.");
		paddress.focus();
		return (false);
	}

	if ( zip.value == "" )
	{
		alert("Enter Property ZIP.");
		zip.focus();
		return (false);
	}

	if ( !isValidZip(zip.value) )
	{
    	alert("This is not valid ZIP code: " + zip.value + " Fill ZIP code again. It must contain 5 digits.");
	    zip.focus();
    	return (false);
	}
	

	if ( zip.value.length != 5 )
	{
		alert("ZIP code have to be with 5 digits.");
		zip.focus();
		return (false);
	}

	if ( city.value == "")
	{
		alert("Enter Property City.");
		city.focus();
		return (false);
	}

	return (true);
}
