//This Function to Check if The User Name is Valid or not...
function isValidUserName(Name){
var re = /^[a-z]{2,}/i;
var matchBegin = Name.match(re);

if (matchBegin == null){
	alert('User Name must begin with at least two characters.');
	return false;
}
else{
	var specialChars =/\(|\)|\\|\[|\]|\>|\<|\?|\/|\.|\,|\'|\;|\:|\||\=|\+|\"|\*|\&|\%|\$|\#|\@|\!|\{|\}/i;
	var matchArray = Name.match(specialChars);
	if (matchArray != null){
		alert('User Name Must not contains any of these characters:\n\( \)\\ \[ \] \> \< \? \/ \. \, \' \; \: \| \= \+ \" \* \& \% \$ \# \@ \! \{ \}.');
		return false;
	}
}
return true;
}

function CheckLogin(theForm){
	if (theForm.MUserName.value == ''){
		alert('Please Enter User Name Field.');
		theForm.MUserName.focus();
		return false;
	}
	else 
		{
			if (isValidUserName(theForm.MUserName.value))  //if the username is valid
				{
					if (theForm.MPassword.value == '')
					{
						alert('Please Enter Password Field.');
						theForm.MPassword.focus();
						return false;
					}
				}
			else 
			 	{
					
					return false;
				}
				

		}
return true;	
}	


