var checkit = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var allValid;

function alphabetonly(checkStr)
{
	allValid=true
	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkit.length; j++)
		if(ch1 == checkit.charAt(j))
			break;
		if (j == checkit.length)
		{
			allValid = false;
			break;
		}
	}
}
////////////////
var checkits = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'";
var allValid2;

function alphabetonly2(checkStr)
{
	allValid2=true
	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkits.length; j++)
		if(ch1 == checkits.charAt(j))
			break;
		if (j == checkits.length)
		{
			allValid2 = false;
			break;
		}
	}
}
//////////////
var checkthis = "0123456789+-/ ";
var allValid1;
function noalphabet(checkStr)
{
	allValid1=true
	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkthis.length; j++)
		if(ch1 == checkthis.charAt(j))
			break;
		if (j == checkthis.length)
		{
			allValid1 = false;
			break;
		}
	}
}


function chk()
{
    if(document.frmindex.name.value=="")
	{
		alert("Please enter first name.")
		document.frmindex.name.focus();
		return false;
	}
	else if(document.frmindex.name.value.charAt(0)==" " || document.frmindex.name.value.charAt(document.frmindex.name.value.length-1)==" ")
	{
		alert("Space is not allowed before or after first name.");
		document.frmindex.name.focus();
		document.frmindex.name.select();
		return false;
	}
	else if(document.frmindex.name.value.length<2)
	{
		alert("Please enter at least 2 characters for first name.")
		document.frmindex.name.focus()
		return false;
	}
	else
	{
		alphabetonly(document.frmindex.name.value);
		if (!allValid)
		{
			alert("Please enter only alphabets for first name.")
			document.frmindex.name.focus();
			return false;
		}
	}  
	  
	


if (document.frmindex.mobileno.value == "")
	{
		alert("Please Enter Mobile No..");
		document.frmindex.mobileno.focus();
		return false;
	}
	else	
	{
		if(validatePhone1(document.frmindex.mobileno.value)==0)		
		{
			document.frmindex.mobileno.select();
			document.frmindex.mobileno.focus();
			return false;
		}
	} 

	if(document.frmindex.Project.value=="")
	{
		alert("Please enter Project.");
		document.frmindex.Project.focus();
		return false;
	}
	if(document.frmindex.type.value=="")
	{
		alert("Please enter	Project type.");
		document.frmindex.type.focus();
		return false;
	}
}


function validatePhone1(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 11 || sPhone.length < 10))
	{
        alert("The mobile number is invalid and should be atleast 10 digit number");
        return 0;	
	}
	else
	{
		return 1;
	}
}