//============================================================================//
// 檢測所指定之表單文字欄位是否輸入正確資料？
//============================================================================//
function ProInvalidTextField( AssignObject , ObjectTitle , AllowEmpty , MinLength ) {
	var Result = false ;
	AssignObject.value = ProTrim( AssignObject.value ) ;
	if ( AssignObject.value == "" ) {
		if ( !AllowEmpty ) {
			alert( "請務必填寫【" + ObjectTitle + "】之欄位資料。" ) ;
			AssignObject.focus() ;
			Result = true ;
		} ;
	} else {
		if ( MinLength > 0 ) {
			if ( AssignObject.value.length < MinLength ) {
				alert( "【" + ObjectTitle + "】欄位資料不得少於" + MinLength + "個英文字。（附註：兩個英文字等於一個中文字）" ) ;
				AssignObject.focus() ;
				Result = true ;
			} ;
		} ;		
	} ;
	return ( Result ) ;
} ;

//============================================================================//
// 檢測所指定之表單帳號欄位是否輸入正確資料？
//============================================================================//
function ProInvalidIDField( AssignObject , ObjectTitle ) {
	var Result = false ;
	var IDLength = AssignObject.value.length ;
	var CheckChar = "" ;
	var ValidCharList = "abcdefghijklmnopqrstuvwxyz_0123456789" ;
	
	AssignObject.value = AssignObject.value.toLowerCase() ;

	for ( var index = 0 ; index < IDLength ; index++ ) {
		CheckChar = AssignObject.value.substring( index , index + 1 ) ;
		if ( ValidCharList.indexOf( CheckChar ) < 0 ) {
			Result = true ;
			break ;
		} ;
	} ;
	
	if ( Result ) { 
		alert( "【" + ObjectTitle + "】欄位必須為英文、數字與下底線 '_' 之組合。" ) ; 
		AssignObject.focus() ; 
	} ;
	return ( Result ) ;
} ;

//============================================================================//
// 檢測所指定之表單整數欄位是否輸入正確資料？
//============================================================================//
function ProInvalidIntegerField( AssignObject , ObjectTitle , AllowZero , AllowMinus , MinValue , MaxValue ) {
	var Result = false ;
	var InputValue = 0 ;	
	try {
	AssignObject.value = ProTrim( AssignObject.value ) ;
	if ( !ProIsInteger( AssignObject.value , AllowMinus ) ) { 
		alert( "【" + ObjectTitle + "】之欄位資料請填入整數數字。" ) ;
		AssignObject.focus() ;
		Result = true ;
		return( Result ) ;
	} ;
	InputValue = parseInt( AssignObject.value , 10 ) ;
	if ( !AllowZero ) {
		if ( InputValue == 0 ) {
			alert( "【" + ObjectTitle + "】之欄位資料不得為 0。" ) ;
			AssignObject.focus() ;
			return( true ) ;
		} ;
	} ;
	if ( MinValue == MaxValue ) { return( Result ) ; } ;
	if ( ( InputValue < MinValue ) || ( InputValue > MaxValue ) ) {
		alert( "【" + ObjectTitle + "】之欄位資料請輸入介於 " + MinValue + " ～ " + MaxValue + "之整數。" ) ;
		AssignObject.focus() ;
		return ( true ) ;
	} ;
	/*
	*/
} catch(E) { alert( E.message ) ; } ;
} ;


//============================================================================//
// 檢測所指定之表單日期欄位是否輸入正確資料？
//============================================================================//
function ProInvalidDateField( YearSelector , MonthSelector , DaySelector , ObjectTitle , ChineseDate ) {
	var Result = true ;
	var AssignDate = "" ;
	var CheckDate = "" ;
	var CheckYear  = parseInt( YearSelector.value , 10 ) ;
	var CheckMonth = parseInt( MonthSelector.value , 10 ) ;
	var CheckDay   = parseInt( DaySelector.value , 10 ) ;

	if ( ChineseDate ) {
		CheckYear = CheckYear + 1911 ;
	} ;
	AssignDate = CheckYear + "/" + CheckMonth + "/" + CheckDay ;
	AssignDate = ProGetDateString( AssignDate , "/" ) ;
	CheckDate = new TDateParser( AssignDate ) ;
	if ( CheckDate.Year == CheckYear ) {
		if ( CheckDate.Month == CheckMonth ) {
			if ( CheckDate.Day == CheckDay ) {
				Result = false ;
			} ;
		} ;
	} ;
	
	if ( Result ) {
		AssignDate = CheckYear + "/" + CheckMonth + "/" + CheckDay ;
		alert( "您所輸入的" + ObjectTitle + " '" + AssignDate + "' 不是一個正確的日期，請重新選擇。" ) ;
		YearSelector.focus() ;
	} ;
	
	CheckDate = null ;
	return ( Result ) ;	
} ;

//============================================================================//
// 檢測所指定之表單浮點數欄位是否輸入正確資料？
//============================================================================//
function ProInvalidFloatField( AssignObject , ObjectTitle , AllowZero , AllowMinus , MinValue , MaxValue ) {
	var Result = false ;
	var InputValue = 0.0 ;	
	try {
		AssignObject.value = ProTrim( AssignObject.value ) ;
		if ( !ProIsNumber( AssignObject.value ) ) { 
			alert( "【" + ObjectTitle + "】之欄位資料請填入整數或小數數字。" ) ;
			AssignObject.focus() ;
			Result = true ;
			return( Result ) ;
		} ;
/*	
	InputValue = parseInt( AssignObject.value , 10 ) ;
	if ( !AllowZero ) {
		if ( InputValue == 0 ) {
			alert( "【" + ObjectTitle + "】之欄位資料不得為 0。" ) ;
			AssignObject.focus() ;
			return( true ) ;
		} ;
	} ;
*/	
	if ( MinValue == MaxValue ) { return( Result ) ; } ;
	if ( ( InputValue < MinValue ) || ( InputValue > MaxValue ) ) {
		alert( "【" + ObjectTitle + "】之欄位資料請輸入介於 " + MinValue + " ～ " + MaxValue + "之整數。" ) ;
		AssignObject.focus() ;
		return ( true ) ;
	} ;
	/*
	*/
} catch(E) { alert( E.message ) ; } ;
} ;

