function MM_jumpMenu(targ,selObj,restore){ //v3.0 if(selObj.options[selObj.selectedIndex].value!="0"){ eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); } if (restore) selObj.selectedIndex=0; } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('\\')+1,filePath.length)); return fileName.substring(fileName.lastIndexOf('.')+1,fileName.length); } function checkFileUpload(field,extensions,txt) { //v1.0 if (extensions && extensions != '') { if (extensions.toUpperCase().indexOf(getFileExtension(field.value).toUpperCase()) == -1) { return txt+'欄位的檔案類型不正確.\n能上傳的檔案類型: ' + extensions + '.\n'; } else{ return''; } }else{ return''; } } function MM_showHideLayers() { //v6.0 var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } obj.visibility=v; } } function windowcenter(w,h){ var w,h,x,y; x=(screen.width-w)/2; y=(screen.height-h)/2; //resizeTo(w,h); moveTo(x,y); } //檢查欄位是否為英文字 function checktexteng(fieldname,msg){ txt=fieldname.value; if(txt!=''){ if(txt.match(/[^a-z|^A-Z]/g)) { fieldname.focus(); alert(msg); //fieldname.value=''; //fieldname.focus(); } } } //檢測計算欄位字元數 function checkfieldwordnum(fieldname,msg,num){ if(fieldname.value.length < num){ alert(msg); //fieldname.focus(); } } function show_day(getdate,pushday){ var WeekDay = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); if(getdate.value!=''){ pushday.value=WeekDay[parseInt(new Date(getdate.value).getDay())]; } } function btn_mod_data_post(formname){ var act; act=confirm("確定要執行?"); if(act){ document.forms[formname].submit(); return true; }else{ $.unblockUI(); return false; } } function add_all(){ for(i=0;i 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function checkimgtype(filename,typelist){//檢查圖片格式,filename 是欄位名稱,typelist是可以通過的格式 用 , 分隔 if(filename=="" || typelist=="") return false; var typelist=typelist.toLowerCase().split(','); var pass_status=1;//0是no pass 1是 pass $('INPUT[name="'+filename+'"]').each(function(index, element) { if($(this).val()!=""){ var filename_chg = $(this).val().toLowerCase(); chk_type_txt=""; var setchk="jpg|gif"; if(typelist.length>0) setchk=""; if(typelist.length>0) var chk_type_txt=typelist.join("|"); if(setchk.length>0) setchk="|"+setchk; var re = eval("/\.("+chk_type_txt+setchk+")$/i"); pass_status=0; //console.log(re); if(re.test(filename_chg))pass_status=1; //console.log(pass_status); } }); //console.log(pass_status); return pass_status; } function chk_field_fun(){//檢查欄位格式是否有填寫或是正確 var error=0; var errmsg=""; $(".formTable input").removeProp("style"); $(".formTable input[data-fieldtype]").each(function(index, element) { //console.log($(this).data("fieldtype")+"-"+$(this).data("enter")); if($(this).data("enter")=="1" && $(this).val()==""){ $(this).css({'border' : '#F00 2px solid'}); errmsg=errmsg+"
--"+$(this).parents('.row').find("label").text().replace(":", "")+"欄位必須填寫"; //console.log($(this).parents('.row').find("label").text()); error=1; }else{ switch($(this).data("fieldtype")){ case "email": if(! isEmail($(this).val())){ $(this).css({'border' : '#F00 2px solid'}); errmsg=errmsg+"
--"+$(this).parents('.row').find("label").text().replace(":", "")+"欄位必須填寫正確格式"; //console.log($(this).parents('.row').find("label").text()); error=1; } break; case "int_number"://整數 if($(this).val().match(/[^0-9]/g)){ $(this).css({'border' : '#F00 2px solid'}); errmsg=errmsg+"
--"+$(this).parents('.row').find("label").text().replace(":", "")+"欄位必須填寫整數數值"; //console.log($(this).parents('.row').find("label").text()); error=1; } break; case "float_number"://數值包含小數 if($(this).val().match(/[^.|^0-9]/g)){ $(this).css({'border' : '#F00 2px solid'}); errmsg=errmsg+"
--"+$(this).parents('.row').find("label").text().replace(":", "")+"欄位必須填寫數值"; //console.log($(this).parents('.row').find("label").text()); error=1; } break; case "test_eng_num"://檢驗欄位除了數字及英文以外不可有其他符號 var re = /^[\d|a-zA-Z0-9]+$/; if(! re.test($(this).val())){ $(this).css({'border' : '#F00 2px solid'}); errmsg=errmsg+"
--"+$(this).parents('.row').find("label").text().replace(":", "")+"欄位必須填寫英文字母或數字"; //console.log($(this).parents('.row').find("label").text()); error=1; } break; case "file": var file_check_type=$(this).data("fileext")!=""?$(this).data("fileext"):"jpg,png,gif,doc,docx,pdf"; if(! checkimgtype($(this).prop("name"),file_check_type)){ $(this).css({'border' : '#F00 2px solid'}); errmsg=errmsg+"
--"+$(this).parents('.row').find("label.col-1").text().replace(":", "")+"檔案格式必須為"+file_check_type+""; error=1; } break; } } }); if(error==1){ return errmsg; }else{ return ""; } } function errordialog(msg){ parent.$("#dialogMask h6").html(' 錯誤訊息'); parent.$("#dialogMask div.Txt").html(msg); parent.$(".dialog_top_pop").trigger("click"); } function msgdialog(msg){ parent.$("#dialogMask h6").html(' 系統訊息'); parent.$("#dialogMask div.Txt").html(msg); parent.$(".dialog_top_pop").trigger("click"); } function checkCreditCard(formValue){ re = /^\d{4}-\d{4}-\d{4}-\d{4}$/; if (!re.test(formValue.value)) alert("你的信用卡號碼不符合「xxxx-xxxx-xxxx-xxxx」的格式!"); } function checkID(formValue){ re = /^[AFC][0-9]{9}$/; if (!re.test(formValue.value)) alert("你的身份證號碼格式不對!"); } function checkMoblie(formValue){ re = /^[09]{2}[0-9]{8}$/; if (!re.test(formValue)){ //alert("你的發票號碼格式不對!"); return false; }else{ return true; } } function checkinvoice(formValue){//發票號碼 re = /^[A-Za-z]{2}[0-9]{8}$/; if (!re.test(formValue)){ //alert("你的發票號碼格式不對!"); return false; }else{ return true; } } function eval_int_number(fieldname){ if(fieldname.value.match(/[^0-9]/g)){ alert('欄位值必須為數字!!'); fieldname.value=''; fieldname.focus(); } } function eval_float_number(fieldname){ if(fieldname.value.match(/[^.|^0-9]/g)){ alert('欄位值必須為數字!!'); fieldname.value=''; fieldname.focus(); } }