/*----------------------------------------------------------------------
  validate name and pass
----------------------------------------------------------------------*/


function checkForm() {
	var myName = document.namePass.formLogin.value;
	var myPass = document.namePass.formPassword.value;
	var error = "";
	if (myName == ""){
		error += "Enter a user name. \n";
	}
	if (myPass == ""){
		error += "Your password can not be blank. \n";
	}
	if (myName.length > 10){
		error += "Sorry your user name has to be 10 characters or less. \n";
		error += myName;
	}
	
	var valchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 -";
	var userError = "";
	for (i = 0; i < myName.length; i++) { 							// check each character 
		if (valchars.indexOf(myName.charAt(i)) == -1){				// to see if it's in the list 
			userError += " "+myName.charAt(i);
		}
	}
	
	if (userError != ""){
		error += "Your user name has at least one illegal character \nthe offending chacter(s) used are ";
		error += userError;
		error += "\n\n";
	}
    
    var illegalPassChars =  /\W/;
    if (illegalPassChars.test(myPass)) {
       error += "Your password has at least one illegal character. Numbers and letters are legal in passwords. All other characters are not allowed \n\n";
    }
	
	if (error == ""){
		return true;
		namePass.submit();
	}else{
		//alert(document.namePass.formLogin.value);
		alert(error);
		return false;
	}
	
	
}

function capLoginName(){
	var LoginName = document.formLogin.formLogin.value;
	LoginName = LoginName.toUpperCase();
	document.formLogin.formLogin.value = LoginName;
}

function checkBoardName(){
	var boardName = document.form1.formBoardName.value;
	error = "";
	
	var valchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 -";
	var userError = "";
	for (i = 0; i < boardName.length; i++) { 							// check each character 
		if (valchars.indexOf(boardName.charAt(i)) == -1){				// to see if it's in the list 
			userError += " "+boardName.charAt(i);
		}
	}
	
	if (userError != ""){
		error += "Your user name has at least one illegal character \nthe offending chacter(s) used are ";
		error += userError;
		error += "\n\n";
	}
	
	if (error == ""){
		return true;
		form1.submit();
	}else{
		//alert(document.namePass.formLogin.value);
		alert(error);
		return false;
	}
	
}

function capBoardName(){
	var boardName = document.form1.formBoardName.value;
	boardName = boardName.toUpperCase();
	if (boardName.length > 10){
		boardName = boardName.substr(0,boardName.length - 1)
	}
	document.form1.formBoardName.value = boardName;
}

function capLength(){
	var myName = document.namePass.formLogin.value;
	myName = myName.toUpperCase();
	if (myName.length > 10){
		myName = myName.substr(0,myName.length - 1)
	}
	document.namePass.formLogin.value = myName;
}
