function check_uid ( uid )
{
if( uid.length <= 0 )
return( "您的帳號還沒填呢 !\n" );
if( uid.length <3 || uid.length> 16 )
return( "您的帳號長度只能 3 至 16 個字元 !\n" );
if ( !(uid.charAt(0)>= 'a' && uid.charAt(0) <= 'z') ) {
return( "您的帳號第一字元只能為小寫字母 !\n" );
}
for( idx = 0 ; idx <uid.length ; idx++ )
{
if( uid.charAt(idx)>= 'A' && uid.charAt(idx) <= 'Z' )
return( "帳號不可以含有大寫字元 !\n" );
if( !( ( uid.charAt(idx)>= 'a' && uid.charAt(idx) <= 'z' ) || ( uid.charAt(idx)>= '0' && uid.charAt(idx) <= '9' ) || ( uid.charAt(idx) == '_' ) ) )
return( "您的帳號只能是數字,英文字母及「_」等符號,其他的符號都不能使用 !\n" );
if( uid.charAt(idx) == '_' && uid.charAt(idx-1) == '_' )
return( "「_」符號不可相連 !\n" );
}
if( uid.indexOf( "fuck" )>= 0 || uid.indexOf( "yos" )>= 0 )
return( "您的帳號不能含有 'fuck' 與 'yos' 的字眼 !\n" );
if( uid.charAt( uid.length - 1 ) == '_' )
return( "「_」符號不可在最後 !\n" );
return "";
}

function check_passwd ( pw1, pw2 )
{
if( pw1 == '' ) {
return ("密碼不可以空白 !\n");
}
for( var idx = 0 ; idx <pw1.length ; idx++ )
if( pw1.charAt(idx) == ' ' || pw1.charAt(idx) == '\"' )
return ("密碼不可以含有空白或雙引號 !\n");
if( pw1.length <4 || pw1.length> 32 )
return( "密碼長度只能 4 到 32 個字母 !\n" );
if( pw1 != pw2 )
return("密碼二次輸入不一樣,請重新輸入 !\n");
return "";
}
function check_null ( column, name )
{
if( column.length == 0 )
return name + "不可以空白 !\n";
return "";
}
function check_select ( select, name )
{
if( select.options[0].selected == true )
return name + "必須選擇 !\n";
return "";
}
function check_radio ( radio, name )
{
var error = true;
for( i=0; i <radio.length; i++ )
if( radio[i].checked == true ) {
error = false;
break;
}
if( error == true )
return name + "必須選擇 !\n";
return "";
}
function check_birthday_year( year )
{
var error = false;
if( year.length != 4 )
return ("您的生日年份必須是四個數字, 例如 1980 年 !\n");
for( idx = 0 ; idx <year.length ; idx++ ) {
if( !( year.charAt(idx)>= '0' && year.charAt(idx) <= '9' ) ) {
error = true;
break;
}
}
if( error == true )
return ("您的生日年份必須是四個數字, 例如 1980 年 !\n");
return "";
}
function check_mobile ( number, radio )
{
var alt = check_radio( radio, "行動電話" );
if( alt.length> 0 )
return alt;
var error = false;
if( radio[1].checked == true ) {
if( number.length <= 0 )
return "您的行動電話還沒填呢 !\n";
if( number.length >= 24 )
return "您的行動電話有問題 !\n";
for( idx = 0 ; idx <number.length ; idx++ ) {
if( !( number.charAt(idx)>= '0' && number.charAt(idx) <= '9' ) && number.charAt(idx)!='-' && number.charAt(idx)!='+' ) {
error = true;
break;
}
}
}
if( error == true )
return "您的行動電話只能是數字, 其他的符號都不能使用 !\n";
else
return "";
}

function check_tel ( number )
{
var error = false;
if( number.length <= 0 )
return "您的通訊電話還沒填呢 !\n";
for( idx = 0 ; idx <number.length ; idx++ ) {
if( !( ( number.charAt(idx)>= '0' && number.charAt(idx) <= '9' ) || ( number.charAt(idx) == '-' ) ) ) {
error = true;
break;
}
}
if( error == true )
return "您的通訊電話只能是數字及'-'等符號, 其他的符號都不能使用 !\n";
return "";
}

function check_num_int ( number,name )
{
var error = false;
if( number.length <= 0 )
return "您的"+name+"還沒填呢 !\n";
for( idx = 0 ; idx <number.length ; idx++ ) {
if( !( ( number.charAt(idx)>= '0' && number.charAt(idx) <= '9' ) || ( number.charAt(idx) == '-' ) ) ) {
error = true;
break;
}
}
if( error == true )
return name +"只能是數字, 其他的符號都不能使用 !\n";
return "";
}

function check_house_room_int ( number )
{
var error = false;
if( number.length <= 0 )
return "您的『位於樓層』還沒填呢 !\n";
for( idx = 0 ; idx <number.length ; idx++ ) {
if( !( ( number.charAt(idx)>= '0' && number.charAt(idx) <= '9' ) || ( number.charAt(idx) == '~' ) ) ) {
error = true;
break;
}
}
if( error == true )
return "您的『位於樓層』只能是數字及'~'等符號, 其他的符號都不能使用 !\n";
return "";
}
