// JavaScript Document

function check_register(th)
{
	if (th.username.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your username!");
		th.username.focus();
		return false;
	}
	if (th.password.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your password!");
		th.password.focus();
		return false;
	}
	if (th.cpassword.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter confirm password!");
		th.cpassword.focus();
		return false;
	}
	if (th.password.value != th.cpassword.value)
	{
		alert ("Both password do not matched!");
		th.cpassword.focus();
		return false;
	}
	
	if (th.name.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your name!");
		th.name.focus();
		return false;
	}
	if (th.email.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your email!");
		th.email.focus();
		return false;
	}
	else if (!emailCheck(th.email.value))
	{
		alert ("Please enter valid email!");		
		th.email.focus();
		return false;	
	}
	if (th.contact.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your contact no");
		th.contact.focus();
		return false;
	}
	if (th.contact.value != "")
	{
		if(isNaN(th.contact.value))	
		{
			alert ("Please enter only digits!");		
			th.contact.focus();
			return false;	
		}
	}
	if (th.address.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your address!");
		th.address.focus();
		return false;
	}
	if (th.city.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your city!");
		th.city.focus();
		return false;
	}
	if (th.zipcode.value.split(" ").join("").length <= 0)
	{
		alert ("Please enter your zipcode!");
		th.zipcode.focus();
		return false;
	}
	if (th.zipcode.value != "")
	{
		if(isNaN(th.zipcode.value))	
		{
			alert ("Please enter only digits!");		
			th.zipcode.select();
			return false;	
		}
	}
}
