var reg1 = /^[0-9a-zA-Z/u4e00-/u9fa5/_]+$/; //判斷只能輸入中文、數字、字母、底線
if(!reg1.test(channelname)){
$("#namemsg").fadeIn(1000);
$("#namemsg").html("<font color=red>由字母、數字、底線、漢字!</font>");
return false;
}
//去除前後空格
channelname=channelname.replace(/(^/s*)|(/s*$)/g, "");
if(channelname=="")
{
$("#namemsg").fadeIn(1000);
$("#namemsg").html("<font color=red>渠道名稱不可為空!</font>");
return false;
}
if(channelname.length > 18 || channelname.length < 3){
$("#namemsg").fadeIn(1000);
$("#namemsg").html("<font color=red>在6-18個字元之間!</font>");
return false;
}
var regPhone=/(^[0-9]{3,4}/-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/;
if (regPhone.test(contactPhone)==false)
{
$("#contactPhonemsg").fadeIn(1000);
$("#contactPhonemsg").html("<font color=red>請檢查您輸入的電話號碼!</font>");
return false;
}
var emailReg=/^([a-zA-Z0-9_/-/./+]+)@((/[[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}/.)|(([a-zA-Z0-9/-]+/.)+))([a-zA-Z]{2,4}
|[0-9]{1,3})(/]?)$/;
if (emailReg.test(contactMail)==false)
{
$("#contactMailmsg").fadeIn(1000);
$("#contactMailmsg").html("<font color=red>郵件格式錯誤!</font>");
return false;
}
//檢查中英文字元長度
function GetLength(value) {
var _tmp = value;
var _length = 0;
for (var i = 0; i < _tmp.length; i++) {
if (_tmp.charCodeAt(i) > 255) {
_length = _length + 2;
}
else {
_length++;
}
}
return _length;
}
//用法:
var _ME = document.forms["form1"];
if (GetLength(_ME.titles.value) > 60) {
alert("標題長度應小於30個漢字(60字元)!");
_ME.titles.focus();
_ME.titles.select();
return false;
}