function checkInput() {
	if (document.getElementById("txtUsername").value.length < 6) {
		alert("使用者名稱至少6個字元。");
		document.getElementById("txtUsername").select();
		return false;
	}
	
	if (document.getElementById("txtPassword").value.length < 8) {
		alert("密碼必須至少8個字元。");
		document.getElementById("txtPassword").focus();
		return false;
	}
	
	if (document.getElementById("txtPassword").value != document.getElementById("txtPassword2").value) {
		alert("密碼與重覆輸入的密碼不相稱，請重新輸入。");
		document.getElementById("txtPassword2").value = "";
		document.getElementById("txtPassword2").focus();
		return false;
	}
	
	if (!checkDOB(document.getElementById("txtDOB_Day").value, 
								document.getElementById("txtDOB_Month").value, 
								document.getElementById("txtDOB_Year").value)
			) { 
			alert("日期格式不對，請重新輸入。");
		  return false;
	}
	
	if (document.getElementById("txtEmail").value == "") {
		alert("電郵地址不能為空白。");
		document.getElementById("txtEmail").focus();
		return false;
	}
	
	return true;
} 

function checkUsername() {
	xajax_processForm(xajax.getFormValues("register"));
}

function y2k(number) { 
	return (number < 1000) ? number + 1900 : number; 
}

function checkDOB(day,month,year) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.

    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) ) {
        return true;
    } else {
        return false;
    }
}
