

function firstNameValidation() {

	if(document.form1.firstname.value == "")
	{
		alert("Please Enter Your First Name");
		document.form1.firstname.focus();
		return false;
	}
	else if (document.form1.firstname.value != "") 
	{
		var regex = /^[a-zA-Z]+[a-zA-Z ]*$/;
		if(!regex.test(document.form1.firstname.value))
		{
			alert("Please Enter Characters ");
			document.form1.firstname.focus();
			return false;
		}
	}
	return true;
}


function lastNameValidation() {

	if(document.form1.lastname.value == "")
	{
		alert("Please Enter Your Last Name");
		document.form1.lastname.focus();
		return false;
	}
	else if (document.form1.lastname.value != "") 
	{
		var regex = /^[a-zA-Z]+[a-zA-Z ]*$/;
		if(!regex.test(document.form1.lastname.value))
		{
			alert("Please Enter Characters ");
			document.form1.lastname.focus();
			return false;
		}
	}
	return true;
}

function budgetValidation() {

	if(document.form1.designation.value == "Select")
	{
		alert("Please Enter Your Budget");
		document.form1.designation.focus();
		return false;
	}
	
	return true;
}


function emailidValidation() {

	if(document.form1.email.value == "")
	{
		alert("Please Enter Your Email Address");
		document.form1.email.focus();
		return false;
	}
	if(document.form1.email.value != "") {
		var regex = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
		if(!regex.test(document.form1.email.value))
		{
			alert("Please Enter Valid EMail Address");
			document.form1.email.value = "";
			document.form1.email.focus();
			return false;
		}
		return true;
	}
}


function homePhoneValidation() {

	if(document.form1.phone.value == "")
	{
		alert("Please Enter Your Primary Phone Number");
		document.form1.phone.focus();
		return false;
	}
	if(document.form1.phone.value != "") {
	var regex = /^[-]?\d*\.?\d*$/;
		if(!regex.test(document.form1.phone.value))
		{
			alert("Please Enter Only Numbers");
			document.form1.phone.value = "";
			document.form1.phone.focus();
			return false;
		}
		return true;
	}
}


function leadTypeValidation() {


	if(document.form1.company.value == "Select")
	{
		alert("Please Select Your Lead Type ");
		document.form1.company.focus();
		return false;
	}

	return true;
}
function websiteValidation() {


	if(document.form1.website.value == "")
	{
		alert("Please Enter Website ");
		document.form1.website.focus();
		return false;
	}

	return true;
}




function DrawCaptcha()
    {
        var a = Math.ceil(Math.random() * 10)+ '';
        var b = Math.ceil(Math.random() * 10)+ '';       
        var c = Math.ceil(Math.random() * 10)+ '';  
        var d = Math.ceil(Math.random() * 10)+ '';  
        var e = Math.ceil(Math.random() * 10)+ '';  
        var f = Math.ceil(Math.random() * 10)+ '';  
        var g = Math.ceil(Math.random() * 10)+ '';  
        var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
        document.getElementById("txtCaptcha").value = code
    }

    // Validate the Entered input aganist the generated security code function   
    function ValidCaptcha(){
        var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
        var str2 = removeSpaces(document.getElementById('txtInput').value);
		
		
		
		
		
        if (str1 != str2) {
			alert("Please validate Correct Code");
document.form1.txtInput.value = "";
document.form1.txtInput.focus();			
			return false;  
			}

        return true;
        
    }

    // Remove the spaces from the entered and generated code
    function removeSpaces(string)
    {
        return string.split(' ').join('');
    }
	
	
	
function hidden() {

	if(document.form1.hidden.value == "")
	{
	
		return true;
	}
	else if (document.form1.firstname.value != "") 
	{
			return false;
	
	}
	return false;
}	
	






function valid()
{
	   
	if(firstNameValidation() &&  lastNameValidation() && emailidValidation() && websiteValidation() && homePhoneValidation() && leadTypeValidation() && budgetValidation() && ValidCaptcha() && hidden() )
	
	{
		return true;
	}
	return false;
}

