function isValidEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;
}

function ValidateUserInput(Name,FieldName)
{
	FieldLength = 3
	if (Name.length < FieldLength)
		{
			alert(FieldName + ' should be at least ' + FieldLength + ' characters')
			return false;
		}

	//var re = /^[a-zA-Z]{2}[A-Za-z0-9]{1,18}$/;

	var re = /^[a-zA-Z]{2}\w{1,18}$/;	

	var matchBegin = Name.match(re);

	if (matchBegin == null){
	alert(FieldName + ' must BEGIN with at least two characters,and contains only characters from a-z or numbers from 0 - 9');
	return false;
	}	

	var specialChars =/\(|\)|\\|\[|\]|\>|\<|\?|\/|\.|\,|\'|\;|\:|\||\=|\+|\"|\*|\&|\%|\ |\$|\#|\@|\!|\{|\}/i;
	var matchArray = Name.match(specialChars);
	if (matchArray != null){
		alert(FieldName + ' Must not contains any of these characters:\n\( \)\\ \[ \] \> \< \? \/ \. \, \' \; \: \| \= \+ \" \* \& \% \$ \# \@ \! \{ \} or space .');
		return false;
	}

return true;

}

function CheckInfo(thisForm){

if (!ValidateUserInput(thisForm.MUserName.value,'Username'))
	return false;

if (!ValidateUserInput(thisForm.MPassword.value,'Password'))
	return false;

if (!ValidateUserInput(thisForm.MRePassword.value,'Confirm Password'))
	return false;

	if (thisForm.MRePassword.value != thisForm.MPassword.value){
		alert('Password Field must match ReType Password Filed.');
		thisForm.MPassword.focus();	
		return false;
	}

	if (!isValidEmail(thisForm.MEmail.value)){
		alert('Invalid Email Address.');	
		thisForm.MEmail.focus();
		return false;
	}
	

	return true;
}

