// ======================Validate Username======================
function ValidateUsername(source, arguments)
{
if ((arguments.Value.length < 6) || (arguments.Value.length > 12)) 
	{
		arguments.IsValid = false;
        return;
	}
	else
	{
		var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
		var checkStr = arguments.Value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
		}
		if (!allValid)
		{
		arguments.IsValid = false;
		return;
		}
	}	
	arguments.IsValid = true;
}

// ======================Validate Password======================
function ValidatePassword(source, arguments)
{
	if ((arguments.Value.length < 6) || (arguments.Value.length > 16)) 
	{
		arguments.IsValid = false;
		return;
	}
	else
	{
		var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
		var checkStr = arguments.Value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
		}
		if (!allValid)
		{
		arguments.IsValid = false;
		return;
		}
	}
	arguments.IsValid = true;
}

// ======================Validate First Name and Last Name ======================
function ValidateName(source, arguments)
{
	if ((arguments.Value.length < 3) || (arguments.Value.length > 30)) 
	{
		arguments.IsValid = false;
		return;
	}
	else
	{
		var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
		var checkStr = arguments.Value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
		}
		if (!allValid)
		{
		arguments.IsValid = false;
		return;
		}
	}
	arguments.IsValid = true;
}

// ======================Validate Address ======================
function ValidateAddress(source, arguments)
{
	if ((arguments.Value.length < 6) || (arguments.Value.length > 60)) 
	{
		arguments.IsValid = false;
		return;
	}
	arguments.IsValid = true;
}

// ======================Validate Batch Code======================
function ValidateBatchCode(source, arguments)
{
	
if (arguments.Value.length != 5) 
	{
		//ready_for_submit = false;
		arguments.IsValid = false;
        return;
	}
	else
	{
		var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		var checkStr = arguments.Value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
		}
		if (!allValid)
		{
		arguments.IsValid = false;
		return;
		}
	}	
	//ready_for_submit=true;
	
	//document.Form1.txtPinBatch_Code.value = arguments.Value.toUpperCase();
	//document.Form1.ddlPinCodeBatch.selected
	
	//var input=document.getElementById('realtxt').value.toLowerCase();
	var input=arguments.Value.toUpperCase();
	var output=document.getElementById('ddlPinCodeBatch').options;
	
	for(var i=0;i<output.length;i++)
	{
		if(output[i].value.indexOf(input)==0)
		{
			output[i].selected=true;
		}
		if(document.forms[0].ddlPinCodeBatch.value=='')
		{
			output[0].selected=true;
		}
	}
	
	document.forms[0].txtPinBatch_Code.value = arguments.Value.toUpperCase();
	arguments.IsValid = true;
}


// ======================Validate News Summary ======================
function ValidateNewsSummary(source, arguments)
{
	if ((arguments.Value.length <= 20) || (arguments.Value.length > 500)) 
	{
		arguments.IsValid = false;
		return;
	}
	arguments.IsValid = true;
}

// ====================== Validate Registration Page ======================

function ValidateRegistrationPage()
{
	var blnValidateUsername = ValidateUsername(document.Form1.txtClient_userName,document.Form1.txtClient_userName)
	alert('blnValidateUsername :' + blnValidateUsername );
	//if (ValidateUsername )
}