function reg_validate()
{	
	var ulen;var passlen;

	if (IsEmpty(document.f1.username,'text'))
	{alert("Please enter your username.");document.f1.username.focus();return false;}
	
	ulen=document.f1.username.value;
	if (ulen.length < 5)
	{alert("Username should be minimum of 5 characters.");document.f1.username.focus();return false;}

	if(!ValidateNo(document.f1.username.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_"))
	{alert("Special characters are not allowed.");document.f1.username.focus();return false;}
	
	if (IsEmpty(document.f1.password,'password'))
	{alert("Please enter your password.");document.f1.password.focus();return false;}

	if(!ValidateNo(document.f1.password.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_"))
	{alert("Special characters are not allowed.");document.f1.password.value="";document.f1.password.focus();return false;}
	
	passlen=document.f1.password.value;
	if (passlen.length < 5)
	{alert("Password should be minimum of 5 characters.");document.f1.password.focus();return false;}

	if (IsEmpty(document.f1.confirmpassword,'password'))
	{alert("Please confirm your password.");document.f1.confirmpassword.focus();return false;}
	
	if (document.f1.password.value!=document.f1.confirmpassword.value)
	{alert("Password does not match.");document.f1.password.value="";document.f1.confirmpassword.value="";
	document.f1.password.focus();return false;}

	if (IsEmpty(document.f1.email,'text'))
	{alert("Please enter your email ID.");document.f1.email.focus();return false;}
	
	if (!(IsEmpty(document.f1.email,'text')))
	{	
		if(emailCheck(document.f1.email.value)==false)
		{
			alert ("Please enter a valid email ID.");document.f1.email.focus();return false;
		}
	}

	if (IsEmpty(document.f1.name,'text'))
	{alert("Please enter your name.");document.f1.name.focus();return false;}

	if(!ValidateNo(document.f1.name.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_ "))
	{alert("Special characters are not allowed.");document.f1.name.focus();return false;}
	
	if (IsEmpty(document.f1.state,'text'))
	{alert("Please enter your state.");document.f1.state.focus();return false;}

	if (IsEmpty(document.f1.city,'text'))
	{alert("Please enter your city.");document.f1.city.focus();return false;}


	
	if(IsEmpty(document.f1.phone,'text') && IsEmpty(document.f1.mobile,'text'))
	{alert("Please enter any one of your contact numbers.");document.f1.phone.focus();return false;}

	if (!IsEmpty(document.f1.phone,'text'))
	{
		if (!ValidateNo(document.f1.phone.value,"1234567890,-+/ "))
		{alert("Invalid phone number.");document.f1.phone.focus();return false;}
		var lancod=document.f1.phone.value;
		if (lancod<11111)
		{alert("Invalid phone number");document.f1.phone.focus();return false;}
		if (lancod.length<5)
		{alert("Phone number should be minimum of 5 digits.");document.f1.phone.focus();return false;}

		if (IsEmpty(document.f1.stdcode,'text'))
		{
		alert ("Please enter the STD code.");
		document.f1.stdcode.focus();
		return false;
		}
       
		
		if (!IsEmpty(document.f1.stdcode,'text'))
		{
		if (!ValidateNo(document.f1.stdcode.value,"1234567890"))
		{alert("Invalid STD Code.");document.f1.stdcode.focus();return false;}
		
		 var stcod1=document.f1.stdcode.value;
		 
		if (stcod1<11)
		{ alert("Invalid STD code");document.f1.stdcode.focus(); return false;}
		
		if (stcod1.length<2)
		{alert("STD code should be minimum of 2 digits.");document.f1.stdcode.focus();return false;}
		}
		
		
	}

	

	if (!IsEmpty(document.f1.mobile,'text'))
	{
		if (!ValidateNo(document.f1.mobile.value,"1234567890,+-/ "))
		{alert("Invalid mobile number.");document.f1.mobile.focus();return false;}
		var mobno=document.f1.mobile.value;
		
		if (mobno<111111)
		{ alert("Invalid mobile number");document.f1.mobile.focus(); return false;}
		
		if (mobno.length<10)
		{alert("Mobile number should be minimum of 10 digits.");document.f1.mobile.focus();return false;}
	}
	
	if (!document.f1.agree.checked)
	{alert("You must agree with our terms and condtions.");document.f1.agree.focus();return false;}

	
	if(document.f1.usernamecheck.value != "")
	{
		alert("Username already exists.");
		document.f1.username.focus();
		return false;
	}
	return true;
	
	if (IsEmpty(document.f1.dealername,'text'))
	{alert("Please enter your dealer name.");document.f1.dealername.focus();return false;}

	if(!ValidateNo(document.f1.dealername.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_ "))
	{alert("Special characters are not allowed.");document.f1.dealername.focus();return false;}
	
	
}

function editreg_validate()
{	
	var ulen;var passlen;

	
	if (IsEmpty(document.f1.email,'text'))
	{alert("Please enter your email ID.");document.f1.email.focus();return false;}
	
	if (!(IsEmpty(document.f1.email,'text')))
	{	
		if(emailCheck(document.f1.email.value)==false)
		{
			alert ("Please enter a valid email ID.");document.f1.email.focus();return false;
		}
	}

	if (IsEmpty(document.f1.name,'text'))
	{alert("Please enter your name.");document.f1.name.focus();return false;}

	if(!ValidateNo(document.f1.name.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_ "))
	{alert("Special characters are not allowed.");document.f1.name.focus();return false;}
	
	


	if (IsEmpty(document.f1.state,'text'))
	{alert("Please enter your state.");document.f1.state.focus();return false;}

	if (IsEmpty(document.f1.city,'text'))
	{alert("Please enter your city.");document.f1.city.focus();return false;}



	if(IsEmpty(document.f1.phone,'text') && IsEmpty(document.f1.mobile,'text'))
	{alert("Please enter any one of your contact numbers.");document.f1.phone.focus();return false;}

	if (!IsEmpty(document.f1.phone,'text'))
	{
		if (!ValidateNo(document.f1.phone.value,"1234567890,-+/ "))
		{alert("Invalid phone number.");document.f1.phone.focus();return false;}
		var lancod=document.f1.phone.value;
		if (lancod.length<5)
		{alert("Phone number should be minimum of 5 digits.");document.f1.phone.focus();return false;}

		if (IsEmpty(document.f1.stdcode,'text'))
		{
		alert ("Please enter STD code.");
		document.f1.stdcode.focus();
		return false;
		}

		if (!IsEmpty(document.f1.stdcode,'text'))
		{
		if (!ValidateNo(document.f1.stdcode.value,"1234567890"))
		{alert("Invalid STD Code.");document.f1.stdcode.focus();return false;}
		var stcod=document.f1.stdcode.value;
		if (stcod.length<2)
		{alert("STD code should be minimum of 2 digits.");document.f1.stdcode.focus();return false;}
		}
	}

	if (!IsEmpty(document.f1.mobile,'text'))
	{
		if (!ValidateNo(document.f1.mobile.value,"1234567890,+-/ "))
		{alert("Invalid mobile number.");document.f1.mobile.focus();return false;}
		var mobno=document.f1.mobile.value;
		if (mobno.length<10)
		{alert("Mobile number should be minimum of 10 digits.");document.f1.mobile.focus();return false;}
	}
	
	
	
	
	return true;
}