﻿function check(){
	if(!trim(form.Topic.value)){alert('請輸入主題');form.Topic.focus();return false;}
	if(!trim(form.Name.value)){alert('請輸入暱稱');form.Name.focus();return false;}
	if(!ischar(form.Name.value)){form.Name.select();return false;}
	if(!form.Gender[0].checked && !form.Gender[1].checked){alert('請選擇性別');form.Gender[0].focus();return false;}	
	if(!trim(form.Content.value)){alert('請輸入內容');form.Content.focus();return false;}
        if(!trim(form.Code.value)){alert('請輸入驗證碼');form.Code.focus();return false;}
        if(!ischar(form.Code.value)){form.Code.select();return false;}
        form.btnSubmit.disabled = true;
        form.submit();
}
function trim(instr){
        return instr.replace(/^[\s]*/gi,'').replace(/[\s]*$/gi,'');
}
function ischar(s){
        var errorChar;
        var badChar = "><[]{}?/\+=|'~!#$%^&()`"; 

        errorChar = isCharsInBagEx(s,badChar);
        if (errorChar != ''){
                alert('請勿輸入特殊字元('+ badChar +')');
                return false;
        }
        return true;
}
function isCharsInBagEx(s,bag){ 
        var i,c;
        for (i = 0; i < s.length; i++){ 
                c = s.charAt(i);
                if (bag.indexOf(c) > -1){
                return c
                }
        }
        return '';
}
function isNumeric(Key){
       if((Key < 48 || Key > 57)){
               window.event.keyCode = 0;
       } 
}
function checkKey(key){
        if((key < 48 || key > 57) && (key < 65 || key > 90) && (key < 97 || key > 122) && (key != 95)){
                window.event.keyCode = 0;
        } 
}
