// JavaScript Document
function isEmailValid(email) 
{ 
    return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w{2,}$/.test(email); 
} 
function myvalidate()
{
		if(document.forms[0].FirstName.value == "")
		{
			alert("Please enter the First Name.");
			document.forms[0].FirstName.focus();
			return false;	
		}
		if(document.forms[0].UserAdd1.value == "")
		{
			alert("Please Enter Address.");
			document.forms[0].UserAdd1.focus();
			return false;	
		}
		if(document.forms[0].city.value == "")
		{
			alert("Please enter city.");
			document.forms[0].city.focus();
			return false;	
		}
		if(document.forms[0].state.value == "")
		{
			alert("Please enter state.");
			document.forms[0].state.focus();
			return false;	
		}
		if(document.forms[0].zip.value == "")
		{
			alert("Please enter Zip/Pin code.");
			document.forms[0].zip.focus();
			return false;	
		}
		if(document.forms[0].phoneno.value == "")
		{
			alert("Please enter phone number.");
			document.forms[0].phoneno.focus();
			return false;	
		}
		
		
		if (parseInt(document.forms[0].phoneno.value) != document.forms[0].phoneno.value) {
			alert('Please enter a number in Phone field for Telephone Number, !numbers only!');
			document.forms[0].phoneno.focus();
			return false;
		}
		if(document.forms[0].email.value == "")
		{
			alert("Email is not given.");
			document.forms[0].email.focus();
			return false;	
		}
		else if(document.forms[0].email.value != "" && !isEmailValid(document.forms[0].email.value))
		{
			alert("Incorrect email id!!");
			document.forms[0].email.focus();
			return false;
		}
		/*if(document.forms[0].Course.options[0].selected)
		{
			alert("Please Select Course!");
			document.forms[0].Course.focus();
			return false;
		}*/
		if(document.forms[0].UserAdd1.value.length > 50)
		{
			alert("Length of Address Line#1 should not be more than 50 characters");
			document.forms[0].UserAdd1.focus();
			return false;
		}
		if(document.forms[0].UserAdd2.value.length > 50)
		{
			alert("Length of Address Line#2 should not be more than 50 characters");
			document.forms[0].UserAdd2.focus();
			return false;
		}
		if(document.forms[0].UserAdd3.value.length > 50)
		{
			alert("Length of Address Line#3 should not be more than 50 characters");
			document.forms[0].UserAdd3.focus();
			return false;
		}
		if(document.forms[0].city.value.length > 30)
		{
			alert("Length of City should not be more than 30 characters");
			document.forms[0].city.focus();
			return false;
		}
		if(document.forms[0].state.value.length > 30)
		{
			alert("Length of State should not be more than 30 characters");
			document.forms[0].state.focus();
			return false;
		}

		if(document.forms[0].zip.value.length > 10)
		{
			alert("Length of zip/pin code should not be more than 10 characters");
			document.forms[0].zip.focus();
			return false;
		}

		if(document.forms[0].phoneno.value.length > 20)
		{
			alert("Length of phone number should not be more than 20 characters");
			document.forms[0].phoneno.focus();
			return false;
		}
		if(document.forms[0].email.value.length > 80)
		{
			alert("Length of email id  should not be more than 80 characters");
			document.forms[0].email.focus();
			return false;
		}
		if(document.forms[0].FirstName.value.length > 30)
		{
			alert("Length of First Name should not be more than 30 characters");
			document.forms[0].FirstName.focus();
			return false;
		}
		if(document.forms[0].MiddleName.value.length > 30)
		{
			alert("Length of Middle Name should not be more than 30 characters");
			document.forms[0].MiddleName.focus();
			return false;
		}
		if(document.forms[0].LastName.value.length > 30)
		{
			alert("Length of Last Name should not be more than 30 characters");
			document.forms[0].LastName.focus();
			return false;
		}
		
		return true;
}



