//FOR ADD頁面公用 //當網頁第一次loading時 依照 type 顯示要的欄位和button $(function(){ //頁簽轉跳簡附文件上傳 $("#goAddDoc").click(function(){ callAdd(); }); $("input[fieldType='period']").datepicker({dateFormat: 'yyyy-mm-dd'}); //checkBox帶值 代 理 人 授權範圍 $("#agentCheckBox").click(function(){ if($(this).is(":checked")){ if($("#agentRightScope").val() == ''){ $("#agentRightScope").val($("#agentCheckText").text()); } } }); //被授權人 權利範圍 $("#rightCheckBox").click(function(){ if($(this).is(":checked")){ if($("#rightScope").val() == ''){ $("#rightScope").val($("#rightCheckText").text()); } } }); if($("#agentDateType").prop("checked")==true){ //未限定期間 畫面載入勾取與否設定 $("#agentEndDate").attr("disabled","true").attr("class","read"); $("#agentStartDate").attr("disabled","true").attr("class","read"); } $("#agentDateType").click(function(){ //代理人限定期間 if($(this).is(":checked")){ $('#agentDateTypeHidden').attr('disabled','true'); $("#agentEndDate").attr("disabled","true").attr("class","read"); $("#agentStartDate").attr("disabled","true").attr("class","read"); $("#agentEndDate").val(""); $("#agentStartDate").val(""); }else{ $('#agentDateTypeHidden').removeAttr('disabled','true'); $("#agentEndDate").removeAttr("disabled").attr("class",""); $("#agentStartDate").removeAttr("disabled").attr("class",""); $("#agentStartDate").css("background-color","rgb(196,211,255)"); $("#agentEndDate").css("background-color","rgb(196,211,255)"); } }); if($("input[name='wfapimmBean.aplLegalType']:checked").val()==undefined){ //身份種類無值給預設為第一個 $("input[name='wfapimmBean.aplLegalType'][value=1]").attr("checked",true); } if($("input[name='wfapimmBean.liceLegalType']:checked").val()==undefined){ //身份種類無值給預設為第一個 $("input[name='wfapimmBean.liceLegalType'][value=1]").attr("checked",true); } //[著作物名稱]的區塊欄位 if($("#isOrgCommodityBlock").prop("checked")==false){ $("#orgName").attr("disabled","true").attr("class","read"); } //[申請人]的區塊欄位 if($("#isApplyKindBlock").prop("checked")==false){ $.each($('.apl'),function(){ //$(this).val(""); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); $.each($('.lice'),function(){ //$(this).val(""); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); $("input[name='wfapimmBean.applyKind']").attr("disabled",true); $("input[name='wfapimmBean.aplLegalType']").attr("disabled",true); $("input[name='wfapimmBean.liceLegalType']").attr("disabled",true); $("input[id='rightCheckBox']").attr("disabled",true); $("input[name='wfapimmBean.applyKind']").attr("checked",false); $("input[name='wfapimmBean.aplLegalType']").attr("checked",false); $("input[name='wfapimmBean.liceLegalType']").attr("checked",false); $("input[id='rightCheckBox']").attr("checked",false); }else{ if($("input[name='wfapimmBean.applyKind']")==1){ $.each($('.lice'),function(){ //$(this).val(""); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); } $("input[name='wfapimmBean.applyKind']").attr("disabled",false); $("input[name='wfapimmBean.aplLegalType']").attr("disabled",false); $("input[name='wfapimmBean.liceLegalType']").attr("disabled",false); $("input[id='rightCheckBox']").attr("disabled",false); $("input[name='wfapimmBean.applyKind']").attr("checked",true); $("input[name='wfapimmBean.aplLegalType']").attr("checked",true); $("input[name='wfapimmBean.liceLegalType']").attr("checked",true); $("input[id='rightCheckBox']").attr("checked",true); } //[代理人]的區塊欄位 if($("#isAgentBlock").prop("checked")==false){ $.each($('.agent'),function(){ //$(this).val(""); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); $("input[name='wfapimmBean.agentLegalType']").attr("disabled",true); $("input[name='wfapimmBean.agentDateType']").attr("disabled",true); $("input[id='agentCheckBox']").attr("disabled",true); $("input[name='wfapimmBean.agentLegalType']").attr("checked",false); $("input[name='wfapimmBean.agentDateType']").attr("checked",false); $("input[id='agentCheckBox']").attr("checked",false); }else{ $("input[name='wfapimmBean.agentLegalType']").attr("disabled",false); $("input[name='wfapimmBean.agentDateType']").attr("disabled",false); $("input[id='agentCheckBox']").attr("disabled",false); $("input[name='wfapimmBean.agentLegalType']").attr("checked",true); $("input[name='wfapimmBean.agentDateType']").attr("checked",true); $("input[id='agentCheckBox']").attr("checked",true); } ////[著作物名稱]的區塊欄位 $("#isOrgCommodityBlock").click(function(){ if($(this).is(":checked")){ $("#orgName").removeAttr("disabled").attr("class",""); $("#orgName").css("background-color","rgb(196,211,255)"); }else{ $("#orgName").attr("disabled","true").attr("class","read"); $("#orgName").val(""); } }); //[申請人]的區塊欄位 $("#isApplyKindBlock").click(function(){ if($(this).is(":checked")){ $.each($('.apl'),function(){ $(this).removeAttr('disabled').css("background-color","rgb(196,211,255)"); }); $("input[name='wfapimmBean.applyKind']").attr("disabled",false); $("input[name='wfapimmBean.aplLegalType']").attr("disabled",false); $("input[name='wfapimmBean.liceLegalType']").attr("disabled",true); $("input[name='wfapimmBean.applyKind'][value=1]").attr("checked",true); $("input[name='wfapimmBean.aplLegalType'][value=1]").attr("checked",true); }else{ $.each($('.lice'),function(){ $(this).val("");; $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); $.each($('.apl'),function(){ $(this).val("");; $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); $("input[name='wfapimmBean.aplLegalType']").attr("disabled",true); $("input[name='wfapimmBean.applyKind']").attr("disabled",true); $("input[name='wfapimmBean.aplLegalType']").attr("disabled",true); $("input[name='wfapimmBean.liceLegalType']").attr("disabled",true); $("input[name='wfapimmBean.applyKind']").attr("checked",false); $("input[name='wfapimmBean.aplLegalType']").attr("checked",false); $("input[name='wfapimmBean.liceLegalType']").attr("checked",false); $("input[id='rightCheckBox']").attr("checked",false); } }); //[代 理 人]的區塊欄位 $("#isAgentBlock").click(function(){ if($(this).is(":checked")){ $.each($('.agent'),function(){ $(this).removeAttr('disabled').css("background-color","rgb(196,211,255)"); }); $("input[name='wfapimmBean.agentLegalType']").attr("disabled",false); $("input[name='wfapimmBean.agentDateType']").attr("disabled",false); $("input[id='agentCheckBox']").attr("disabled",false); }else{ $.each($('.agent'),function(){ $(this).val(""); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); $("input[name='wfapimmBean.agentLegalType']").attr("disabled",true); $("input[name='wfapimmBean.agentDateType']").attr("disabled",true); $("input[id='agentCheckBox']").attr("disabled",true); $("input[name='wfapimmBean.agentLegalType']").attr("checked",false); $("input[name='wfapimmBean.agentDateType']").attr("checked",false); $("input[id='agentCheckBox']").attr("checked",false); } }); }); //設定 畫面因表單不同所呈現字樣也不同(商標權人<=>著作權人) $(function(){ var formId=$("#formId").val(); if(formId=="WW901"){ $("#agentCheckText").html("包含向海關申請檢舉保護商標權案件相關事宜"); $("#rightCheckText").html("包含向海關申請檢舉保護商標權案件相關事宜"); } if(formId=="WW902"){ $("#agentCheckText").html("包含向海關申請提示保護商標權案件相關事宜"); $("#rightCheckText").html("包含向海關申請提示保護商標權案件相關事宜"); } if(formId=="WW903"){ $("#agentCheckText").html("包含向海關申請檢舉保護著作權案件相關事宜"); $("#rightCheckText").html("包含向海關申請檢舉保護著作權案件相關事宜"); $("#radioFirstCol").html("同著作權人"); $("#aaa").html("申請人︵著作權人︶"); } if(formId=="WW904"){ $("#agentCheckText").html("包含向海關申請提示保護著作權案件相關事宜"); $("#rightCheckText").html("包含向海關申請提示保護著作權案件相關事宜"); $("#radioFirstCol").html("同著作權人"); $("#aplType").html("申請人︵著作權人︶"); } if(formId=="WW905"){ $("#agentCheckText").html("包含向海關申請延長提示保護商標權案件相關事宜"); $("#rightCheckText").html("包含向海關申請延長提示保護商標權案件相關事宜"); $("#agentUploadFile").html("委任書日期如有更動,請自行更新上傳代理人授權證明文件。"); } if(formId=="WW906"){ $("#agentCheckText").html("包含向海關申請延長提示保護著作權案件相關事宜"); $("#rightCheckText").html("包含向海關申請延長提示保護著作權案件相關事宜"); $("#radioFirstCol").html("同著作權人"); $("#agentUploadFile").html("委任書日期如有更動,請自行更新上傳代理人授權證明文件。"); $("#aplType").html("申請人︵著作權人︶"); } if(formId=="WW908"){ $("#agentCheckText").html("包含向海關申請延長提示保護商標權案件相關事宜"); $("#rightCheckText").html("包含向海關申請延長提示保護商標權案件相關事宜"); $("#agentUploadFile").html("委任書日期如有更動,請自行更新上傳代理人授權證明文件。"); } if(formId=="WW910"){ $("#agentCheckText").html("包含向海關申請延長提示保護著作權案件相關事宜"); $("#rightCheckText").html("包含向海關申請延長提示保護著作權案件相關事宜"); $("#radioFirstCol").html("同著作權人"); $("#agentUploadFile").html("委任書日期如有更動,請自行更新上傳代理人授權證明文件。"); $("#aplType").html("申請人︵著作權人︶"); } }); function submitCheck(){ var msg=""; if(!($("#privateCheck").is(":checked"))){ //個人資料隱私權保護聲明 if(!($("#type").val()=="add")){ //edit狀態 時 只有 0 未送出 和 退回補正 3 msg+="請勾選[隱私權保護聲明]"; } } if(!($("#trueCheck").is(":checked"))){ //本申請書所填寫之資料係為真實 if(!($("#type").val()=="add")){ msg+=" 請勾選[本申請書所填寫之資料係為真實]"; $('#statusMsg').val(msg).css("color","red"); } } if(msg.length>0){ $('#statusMsg').val(msg).css("color","red"); return true; }else{ return false; } } /** * 依據應收送達人 決定該選取人之E-MAIL為必填 * */ function emailIsEmptyCheck(){ var receiverType = $("input[name='wfapimmBean.receiverType']:checked").val(); //應收送達人1 or2 or 3 switch(parseInt(receiverType)){ case 1: $.each($(".apl"),function(){ //class=apl(將必填欄位歸類) $(this).attr("mustFill","must"); }); $.each($(".lice"),function(){ $(this).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); $.each($(".agent"),function(){ $(this).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); break; case 2: $.each($(".apl"),function(){ $(this).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); $.each($(".lice"),function(){ $(this).attr("mustFill","must"); }); $.each($(".agent"),function(){ $(this).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); break; case 3: $.each($(".apl"),function(){ $(this).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); $.each($(".lice"),function(){ $(this).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); $.each($(".agent"),function(){ $(this).attr("mustFill","must"); }); break; } } //本申請案若無被授權人,則可不必填寫 //本申請案若無代理人,則可不必填寫 function fieldSecondary(){ var isEmpty=false; if($("input[name='wfapimmBean.agentLegalName']").val().length!=0){ if($("#agentRightScope").val().length!=0){ //已填 $("#agentRightScope").css("background-color","rgb(196,211,255)"); }else{ //未填 $("#agentRightScope").css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } if($("#agentDateType").prop("checked")==false){ //未限定期間 畫面載入勾取與否設定 if($("#agentStartDate").val().length!=0 && $("#agentEndDate").val().length!=0 ){ $("#agentStartDate").css("background-color","rgb(196,211,255)"); $("#agentEndDate").css("background-color","rgb(196,211,255)"); } else { $("#agentEndDate").css("background-color",'#FF7573'); $("#agentStartDate").css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } } }else{ $("#agentRightScope").css("background-color","rgb(196,211,255)"); $("#agentStartDate").css("background-color","rgb(196,211,255)"); $("#agentEndDate").css("background-color","rgb(196,211,255)"); } if($("input[name='wfapimmBean.liceName']").val().length!=0){ if($("#rightScope").val().length!=0){ //已填 $("#rightScope").css("background-color","rgb(196,211,255)"); }else{ //未填 $("#rightScope").css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } //專屬被授權人 之身分種類如果非 自然人 則需填寫代表人欄位 if($("input[name='wfapimmBean.liceLegalType']:checked").val()!=1&&$("#liceLegalName").val().length==0){ $("#liceLegalName").css("background-color",'#FF7573'); isEmpty=true; }else{ $("#liceLegalName").css("background-color","rgb(196,211,255)"); } }else{ $("#rightScope").css("background-color","rgb(196,211,255)"); $("#liceLegalName").css("background-color","rgb(196,211,255)"); } //商標權人 之身分種類如果非 自然人 則需填寫代表人欄位 if($("input[name='wfapimmBean.aplLegalType']:checked").val()!=1&&$("#aplLegalName").val().length==0){ $("#aplLegalName").css("background-color",'#FF7573'); isEmpty=true; }else{ $("#aplLegalName").css("background-color","rgb(196,211,255)"); } return isEmpty; } //應收送達人是否選擇 function checkReceiverType(){ if(0==$("input[name='wfapimmBean.receiverType']:checked").length){ return true; }else{ return false; } } function checkEmail(){ //檢查 Email var emailRule = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/; var isMailNotOK=false; $("input[name*=Email]").each(function(){ if($(this).val()==""||emailRule.test($(this).val())){ //沒填值或格式吻合 $(this).css("background-color","rgb(196,211,255)"); }else{ $(this).css("background-color",'#FF7573'); isMailNotOK=true; } }); return isMailNotOK; } function checkCompanyId(sid){ //檢查公司統編 回傳 true為錯誤 if(sid==null){ return false; }else{ var tbNum = new Array(1,2,1,2,1,2,4,1); var temp = 0; var total = 0; sid=$.trim(sid); if(!sid.match(/^\d{8}$/)){ return true; }else{ for(var i = 0; i < tbNum.length ;i ++){ temp = sid.charAt(i) * tbNum[i]; total += Math.floor(temp/10)+temp%10; } if(total%5==0 || (total%5==4 && sid.charAt(6)==7)){ return false; }else{ return true; } } } } function checkPersonID(id) { //檢查身分證字號 回傳true為正確 if(id==null){ return true; } tab = "ABCDEFGHJKLMNPQRSTUVXYWZIO"; A1 = new Array (1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3 ); A2 = new Array (0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 ); Mx = new Array (9,8,7,6,5,4,3,2,1,1); if ( id.length != 10 ) return false; i = tab.indexOf( id.charAt(0) ); if ( i == -1 ) return false; sum = A1[i] + A2[i]*9; for ( var i=1; i<10; i++ ) { v = parseInt( id.charAt(i) ); if ( isNaN(v) ) return false; sum = sum + v * Mx[i]; } if ( sum % 10 != 0 ) return false; return true; } //20150126 ADD AlexWang //檢查居留證格式 回傳true為正確 function isLiveID(str_){ //alert( str_ ); if(str_ == null){ return true; } if (! /^[a-zA-Z]{1}[a-dA-D1-2]{1}[0-9]{8}$/.test(str_)) { return false; } else { var id_ = str_.toUpperCase(); var sum = 0; var str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var str2 = "1011121314151617341819202122352324252627282932303133"; var t1 = str2.substr(str1.indexOf(id_.substr(0,1)) * 2 ,2); var t2 = str2.substr(str1.indexOf(id_.substr(1,1)) * 2 ,2); sum = t1.substr(0,1) * 1 + t1.substr(1,1) * 9; sum += (t2 % 10 ) * 8; var t10 = id_.substr(9,1); for (t_i = 3; t_i <= 9; t_i++) { sum += id_.substr(t_i-1,1) * (10 - t_i); } (sum % 10 == 0 ) ? t10_ = 0 : t10_ = 10 - (sum % 10); return (t10_ == t10 ) ? true : false; } } function checkDate(b,e){ //比較日期起迄日 if(e-b<0){ return true; }else{ return false; } } function checkDateFormat(){ var dateValue; var mon; var day; var returnValue=false; $("input[fieldType='period']").each(function(){ var dateString =$(this).val(); if(dateString.length!=0){ dateValue=$(this).val().split("/"); mon=parseInt(dateValue[1]); day=parseInt(dateValue[2]); if(mon>12||day>31||isNaN(mon)||isNaN(day)){ $(this).css("background-color",'#FF7573'); returnValue=true; }else{ $(this).css("background-color","rgb(196,211,255)"); } } }); return returnValue; } function dateCheck(){ //使日期只能為數字(備用) var rule=/^[0-9]+$/; rule.test(value); } function regNoCheck(regNo){ // *商標註冊號數: if(regNo==undefined||regNo.length==0){ //表單沒這個欄位或沒填值 return false; }else if(regNo.length!=8) //有值但不等於8 return true; return false; } function checkDoc(actionUrl){ //檢查必上傳之檔案 docMsg=""; var hasDoc; upLoadAttachTypeArray.push(checkAgent()); //判斷有無代理人 有需上傳代理人檔案 return $.post(actionUrl+"!checkUpDoc",{"wfapimmBean.caseNo":$("#caseNo").val()},function(data){ var attachArray=$.parseJSON(data.data.attachArray); //後端回傳有上傳檔案之文件以 array 形式 $.each(upLoadAttachTypeArray,function(index){ hasDoc=attachArray.indexOf(this); if(hasDoc==-1){ switch(parseInt(this)){ case 3: docMsg+="[請上傳權利證明文件]"; break; case 5: docMsg+="[請上傳代理證明文件]"; break; case 10: docMsg+="[請同時上傳(真品)及(仿品)辨識照片 或 單獨上傳(真仿品)辨識照片]"; break; case 11: docMsg+="[請上傳延展註冊核准函或商標註冊簿]"; break; } } }); }); } function checkAgent(){ //確認代理人欄位有無值 有=>需上傳檔案 var hasValue = $.trim($("input[name='wfapimmBean.agentName']").val()).length!=0; if("WW905"!=$("#formId").val()&&"WW906"!=$("#formId").val()){ //WW905 906 可不必上傳代理人 if(hasValue){ return 5; } } } //判斷[申請人]統編/身分證字號檢核 function checkIdno($aplLegalType,$aplIdno,$liceLegalType,$liceIdno,$agentLegalType,$agentIdno){ var isAplIdnoNotOk=checkEachIdno($aplLegalType,$aplIdno); var isLiceIdnoNotOk=checkEachIdno($liceLegalType,$liceIdno); var isAgentIdnoNotOk=checkAgentIdno($agentLegalType,$agentIdno); if(isAplIdnoNotOk||isLiceIdnoNotOk||isAgentIdnoNotOk){ return true; } return false; } /* * 回傳true,代表有問題 * 回傳false,代表沒有問題 */ function checkEachIdno($legalType,$idno){ if($idno.val()!=""){ if($legalType.val()==1){ if(!(checkPersonID($idno.val()))){ $idno.css("background-color",'#FF7573'); return true; //checkPersonID(id)回傳true為正確 } }else{ if(checkCompanyId($idno.val())){ $idno.css("background-color",'#FF7573'); return true; //checkCompanyId(sid)回傳true為錯誤 } } //20150126 ADD Alex /*if($legalType.val()==2){ if(!(isLiveID($idno.val()))){ $idno.css("background-color",'#FF7573'); return true; //checkPersonID(id)回傳true為正確 } }*/ } $idno.css("background-color","rgb(196,211,255)"); return false; } //判斷[代理人]身分證字號/居留證檢核 /* * 回傳true,代表有問題 * 回傳false,代表沒有問題 */ function checkAgentIdno($legalType,$idno){ //alert("legalType="+$legalType.val()); //alert("idno="+$idno.val()); if($idno.val()!=""){ if($legalType.val()==1){ if(!(checkPersonID($idno.val()))){ $idno.css("background-color",'#FF7573'); return true; //checkPersonID(id)回傳true為正確 } } //20150126 ADD Alex if($legalType.val()==4){ //alert("SSSSS"); if(!(isLiveID($idno.val())) && !(newId11Check($idno.val()))){ $idno.css("background-color",'#FF7573'); return true; //checkPersonID(id)回傳true為正確 } } } $idno.css("background-color","rgb(196,211,255)"); return false; } //PRINT SCRIPT $(function(){ var formId=$("#formId").val(); $( '#print' ).viewReport({ url : formId+'NoSign!print', module : 'ww', jasperFileName : formId+'_RPT', outputFileName : formId+'_RPT', conditionFormSelector : $( "#"+formId ), isPost : true, reportType : 'pdf' //optional, report type, 目前只有提供 "pdf", "excel", "word", "html" "text" }); }); //下載個人隱私文件專用 function downLoadFile(){ $("#forDownLoad").attr('target','downloadFrame'); $("#forDownLoad").attr("action","WF01_loadFile").submit(); } //IE8對 textarea限制欄位失效 $('textarea[maxlength]').live('blur', function() { // Store the maxlength and value of the field. var maxlength = $(this).attr('maxlength'); var val = $(this).val(); // Trim the field if it has content over the maxlength. if (val.length > maxlength) { alert("欄位字數超過"+maxlength+"字"); $(this).val(val.slice(0, maxlength)); } }); function checkCustomsNo(){ var customsNo= $("input[name='wfapimmBean.customsNo']").val(); if(customsNo==null) { $("input[name='wfapimmBean.customsNo']").css("background-color","rgb(196,211,255)"); return false; } if(customsNo.length<11) { $("input[name='wfapimmBean.customsNo']").css("background-color",'#FF7573'); //紅色底 return true; } $("input[name='wfapimmBean.customsNo']").css("background-color","rgb(196,211,255)"); //藍色底 return false; } function checkUpdateItem(){ var errItem =0; if($("#isApplyKindBlock").prop("checked")==true && $("#isAgentBlock").prop("checked")==false){ //申請人 if($("input[name='wfapimmBean.applyKind']:checked").val() == 1 && $("input[name='wfapimmBean.receiverType']:checked").val() == 2){ errItem=1; } else if($("input[name='wfapimmBean.applyKind']:checked").val() == 2 && $("input[name='wfapimmBean.receiverType']:checked").val() == 1){ errItem=1; } else if(($("input[name='wfapimmBean.applyKind']:checked").val() == 1 || $("input[name='wfapimmBean.applyKind']:checked").val() == 2) && $("input[name='wfapimmBean.receiverType']:checked").val() == 3){ errItem=2; } } else if($("#isAgentBlock").prop("checked")==true && $("#isApplyKindBlock").prop("checked")==false){ //代理人 if($("input[name='wfapimmBean.receiverType']:checked").val() == 1){ errItem=4; } if($("input[name='wfapimmBean.receiverType']:checked").val() == 2){ errItem=4; } } else if($("#isApplyKindBlock").prop("checked")==true && $("#isAgentBlock").prop("checked")==true){ if($("input[name='wfapimmBean.applyKind']:checked").val() == 1 && $("input[name='wfapimmBean.receiverType']:checked").val() == 2){ errItem=1; } else if($("input[name='wfapimmBean.applyKind']:checked").val() == 2 && $("input[name='wfapimmBean.receiverType']:checked").val() == 1){ errItem=1; } } return errItem; } function checkField1(){ //錯誤驗證 var agentStartDate = new Date($("input[name='wfapimmBean.agentStartDate']").val()); //代理人日期(起迄) var agentEndDate = new Date($("input[name='wfapimmBean.agentEndDate']").val()); var $aplLegalType = $("input[name='wfapimmBean.aplLegalType']:checked"); //申請人(商標/著作權人)身分種類 var $aplIdno =$("input[name='wfapimmBean.aplIdno']"); //申請人(商標/著作權人)統編/身分證號 var $liceLegalType = $("input[name='wfapimmBean.liceLegalType']:checked"); //專屬被授權人(商標/著作權人)身分種類 var $liceIdno =$("input[name='wfapimmBean.liceIdno']"); //專屬被授權人(商標/著作權人)統編/身分證號 var $agentLegalType = $("input[name='wfapimmBean.agentLegalType']:checked"); //代理人預設值為1的hidden欄位,可能可以從這邊改 var $agentIdno = $("input[name='wfapimmBean.agentIdno']"); //代理人身分證號 var msg=""; // emailIsEmptyCheck(); //判斷勾選之應收送達人 給予email 為必填欄位 if(fieldIsEmpty()){ //必填欄位 msg="[請填寫有標記紅色背景及星號之欄位。]"; $('#statusMsg').val(msg).css("color","red"); return true; } if($("#isAgentBlock").prop("checked")){ if($("input[name='wfapimmBean.agentLegalType']:checked").val() == undefined){ msg+="[請選擇[代理人]的區塊身份種類之欄位]"; } } if(checkIdno($aplLegalType,$aplIdno,$liceLegalType,$liceIdno,$agentLegalType,$agentIdno)){ // 統編/身分證字號 msg+="[請填寫正確之統編/身分證號]"; } if(msg!=""){ //在此先顯示一回錯誤訊息 $('#statusMsg').val(msg).css("color","red"); return true; } if(checkEmail()){ //檢查Email msg+="[電子信箱格式有誤!]"; } if(checkDate(agentStartDate,agentEndDate)){ //代理人日期(起迄) msg+="[代理人日期期間起日不可大於迄日!]"; } if(regNoCheck($("input[name='wfapimmBean.regNo']").val())){ //商標註冊 msg+="[商標註冊號數必須為8碼]"; } if(regNoCustomsNo($("input[name='wfapimmBean.customsNo']").val())){ //海關受理編號 msg+="[海關受理編號必須為11碼]"; } //檢核郵遞區號 if(checkAddr() != ""){ msg += checkAddr(); } /*if(chkAddrCode() != ""){ msg += chkAddrCode(); }*/ if(msg!=""){ $('#statusMsg').val(msg).css("color","red"); return true; }else{ return false; } } function fieldIsEmpty(){ //必填欄位 var isEmpty=false; if($("#isOrgCommodityBlock").prop("checked")==true){ $("#abgne_tab, input[mustFill='mustb'], textarea[mustFill='mustb'] ").each(function( index ) { if($(this).val().length!=0){ //已填 $(this).css("background-color","rgb(196,211,255)"); }else{ //未填 $(this).css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } }); } /*if($('input:radio:checked[name="wfapimmBean.receiverType"]').val()==1){ $("#abgne_tab, input[mustFill='must1'], textarea[mustFill='must1'] ").each(function( index ) { if($(this).val().length!=0){ //已填 $(this).css("background-color","rgb(196,211,255)"); }else{ //未填 $(this).css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } }); }else if($('input:radio:checked[name="wfapimmBean.receiverType"]').val()==2){ $("#abgne_tab, input[mustFill='must2'], textarea[mustFill='must2'] ").each(function( index ) { if($(this).val().length!=0){ //已填 $(this).css("background-color","rgb(196,211,255)"); }else{ //未填 $(this).css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } }); } else if($('input:radio:checked[name="wfapimmBean.receiverType"]').val()==3){ //代理人 $("#abgne_tab, input[mustFill='must3'], textarea[mustFill='must3'] ").each(function( index ) { if($(this).val().length!=0) { $(this).css("background-color","rgb(196,211,255)"); }else if( $('#agentDateType').prop("checked") && ($(this).prop("id") == "agentStartDate" || $(this).prop("id") == "agentEndDate")) { // 代理期間未限定 $(this).css("background-color","rgb(196,211,255)"); }else { $(this).css("background-color",'#FF7573'); isEmpty=true; } }); }*/ if($("#isApplyKindBlock").prop("checked")==true){ if($("input[name='wfapimmBean.applyKind']:checked").val() == 1){ $("#abgne_tab, input[mustFill='must1'], textarea[mustFill='must1'] ").each(function( index ) { if($(this).val().length!=0){ //已填 $(this).css("background-color","rgb(196,211,255)"); }else{ //未填 $(this).css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } }); } else if($("input[name='wfapimmBean.applyKind']:checked").val() == 2){ $("#abgne_tab, input[mustFill='must2'], textarea[mustFill='must2'] ").each(function( index ) { if($(this).val().length!=0){ //已填 $(this).css("background-color","rgb(196,211,255)"); }else{ //未填 $(this).css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } }); } } if($("#isAgentBlock").prop("checked")==true){ //代理人 $("#abgne_tab, input[mustFill='must3'], textarea[mustFill='must3'] ").each(function( index ) { if($(this).val().length!=0) { $(this).css("background-color","rgb(196,211,255)"); }else if( $('#agentDateType').prop("checked") && ($(this).prop("id") == "agentStartDate" || $(this).prop("id") == "agentEndDate")) { // 代理期間未限定 $(this).css("background-color","rgb(196,211,255)"); }else { $(this).css("background-color",'#FF7573'); isEmpty=true; } }); } $("#abgne_tab, input[mustFill='must'], textarea[mustFill='must'] ").each(function( index ) { if($(this).val().length!=0){ //已填 $(this).css("background-color","rgb(196,211,255)"); }else{ //未填 $(this).css("background-color",'#FF7573'); isEmpty=true; //有一個未填就true } }); return isEmpty; } /** * 依據申請人類別 決定該填寫商標權人/專屬被授權人 * */ function applyKindChage(){ applyKind = $("input[name='wfapimmBean.applyKind']:checked").val(); //申請人類別:1(商標權人) or 2(專屬被授權人) if($("#isApplyKindBlock").prop("checked")==true){ switch(parseInt(applyKind)){ case 1: var aplMustFields = [ 'wfapimmBean.aplName', 'wfapimmBean.aplEname', 'wfapimmBean.aplAddr', 'wfapimmBean.aplEmail', 'wfapimmBean.aplTelNo', 'wfapimmBean.aplFaxNo' ]; setApplyKind(aplMustFields,'.apl','.lice'); $("input[name='wfapimmBean.aplLegalType'][value=1]").attr("checked",true); //[專屬被授權人]身份種類 $("input[name='wfapimmBean.aplLegalType']").attr("disabled",false); $("input[name='wfapimmBean.liceLegalType']").attr("checked",false); //[商標權人]身份種類 $("input[name='wfapimmBean.liceLegalType']").attr("disabled",true); break; case 2: liceMustFields = [ 'wfapimmBean.liceName', 'wfapimmBean.liceEname', 'wfapimmBean.liceAddr', 'wfapimmBean.liceEmail', 'wfapimmBean.liceTelNo', 'wfapimmBean.liceFaxNo', 'wfapimmBean.rightScope' ]; setApplyKind(liceMustFields,'.lice','.apl'); $("input[name='wfapimmBean.liceLegalType'][value=1]").attr("checked",true); //[專屬被授權人]身份種類 $("input[name='wfapimmBean.liceLegalType']").attr("disabled",false); $("input[name='wfapimmBean.aplLegalType']").attr("disabled",true); $("input[name='wfapimmBean.aplLegalType']").attr("checked",false); //[商標權人]身份種類 break; } } } function setApplyKind(mustFields,MustCssName,NoMustCssName){ /*for ( var index in mustFields) { var id = $("input[name='"+mustFields[index]+"']"); id.attr("mustFill","must"); }*/ $.each($(MustCssName),function(){ $(this).removeAttr('disabled').css("background-color","rgb(196,211,255)"); }); $.each($(NoMustCssName),function(){ $(this).val(""); //$(this).removeAttr("mustFill"); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); } function checkAddr(){ var msg = ""; //var chkAddr= false; //商標權人 if( ($("#aplAddrCode").val() == '' && $("#aplAddr").val() != '') || ($("#aplAddrCode").val() != '' && $("#aplAddr").val() == '') ){ msg += "[申請人(商標權人)郵遞區號、地址欄位輸入不完全]"; //chkAddr = true; $("#aplAddrCode").css("background-color",'#FF7573'); $("#aplAddr").css("background-color",'#FF7573'); }else{ $("#aplAddrCode").css("background-color",'rgb(196,211,255)'); $("#aplAddr").css("background-color",'rgb(196,211,255)'); } //專屬被授權人 if( ($("#liceAddr").val() == '' && $("#liceAddrCode").val() != '') || ($("#liceAddr").val() != '' && $("#liceAddrCode").val() == '') ){ msg+="[申請人(專屬被授權人)郵遞區號、地址欄位輸入不完全]"; //chkAddr = true; $("#liceAddrCode").css("background-color",'#FF7573'); $("#liceAddr").css("background-color",'#FF7573'); }else{ $("#liceAddrCode").css("background-color",'rgb(196,211,255)'); $("#liceAddr").css("background-color",'rgb(196,211,255)'); } //代理人 if( ($("#agentAddr").val() == '' && $("#agentAddrCode").val() != '') || ($("#agentAddr").val() != '' && $("#agentAddrCode").val() == '') ){ msg+="[代理人郵遞區號、地址欄位輸入不完全]"; //chkAddr = true; $("#agentAddrCode").css("background-color",'#FF7573'); $("#agentAddr").css("background-color",'#FF7573'); }else{ $("#agentAddr").css("background-color",'rgb(196,211,255)'); $("#agentAddr").css("background-color",'rgb(196,211,255)'); } //return chkAddr; return msg; } function chkAddrCode(){ var msg = ""; //商標權人 if( $("#aplAddrCode").val() != '' && $("#aplAddr").val() != '' ){ if(!($("#aplAddrCode").val().length == 3 || $("#aplAddrCode").val().length == 5 || $("#aplAddrCode").val().length == 6)){ msg += "[申請人(商標權人)郵遞區號必須為3碼、5碼或6碼數字]"; $("#aplAddrCode").css("background-color",'#FF7573'); }else{ $("#aplAddrCode").css("background-color",'rgb(196,211,255)'); $("#aplAddr").css("background-color",'rgb(196,211,255)'); } }else{ $("#aplAddrCode").css("background-color",'rgb(196,211,255)'); $("#aplAddr").css("background-color",'rgb(196,211,255)'); } //專屬被授權人 if( $("#liceAddrCode").val() != '' && $("#liceAddr").val() != '' ){ if(!($("#liceAddrCode").val().length == 3 || $("#liceAddrCode").val().length == 5 || $("#liceAddrCode").val().length == 6)){ msg += "[申請人(專屬被授權人)郵遞區號必須為3碼、5碼或6碼數字]"; $("#liceAddrCode").css("background-color",'#FF7573'); }else{ $("#liceAddrCode").css("background-color",'rgb(196,211,255)'); $("#liceAddr").css("background-color",'rgb(196,211,255)'); } }else{ $("#liceAddrCode").css("background-color",'rgb(196,211,255)'); $("#liceAddr").css("background-color",'rgb(196,211,255)'); } //代理人 if( $("#agentAddrCode").val() != '' && $("#agentAddr").val() != '' ){ if(!($("#agentAddrCode").val().length == 3 || $("#agentAddrCode").val().length == 5 || $("#agentAddrCode").val().length == 6)){ msg += "[代理人郵遞區號必須為3碼、5碼或6碼數字]"; $("#agentAddrCode").css("background-color",'#FF7573'); }else{ $("#agentAddrCode").css("background-color",'rgb(196,211,255)'); $("#agentAddr").css("background-color",'rgb(196,211,255)'); } }else{ $("#agentAddrCode").css("background-color",'rgb(196,211,255)'); $("#agentAddr").css("background-color",'rgb(196,211,255)'); } return msg; } function regNoCustomsNo(customsNo){ if(customsNo==undefined || customsNo.length==0){ //表單沒這個欄位或沒填值 return true; }else if(customsNo.length!=11){ //有值但不等於11 return true; }else{ return false; } } //判斷居留證 回傳true為正確 false為錯誤 function newId11Check(src) { //居留證為兩碼英文加八碼數字 or 居留證為1碼英文加9碼數字 新版 if (src.match('^[a-zA-Z]{1}[8-9]{1}[0-9]{8}$') === null){ return false; } var result = 0; var srcMap = src.split(""); var num = ["10", "11", "12", "13", "14", "15", "16", "17", "34", "18", "19", "20", "21", "22", "35", "23", "24", "25", "26", "27", "28", "29", "32", "30", "31", "33"]; var fPos = srcMap[0].charCodeAt() - ('A').charCodeAt(); var fNum = (parseInt(num[fPos][0]) + parseInt(num[fPos][1])*9); var sPos = (srcMap[1]*8).toString().split(""); var sNum0 = parseInt(sPos[0]); var sNum1 = parseInt(sPos[1]); for (i = 2; i < 9; i++) { result = result + (parseInt(srcMap[i]) * (9 - i)); } result = result + fNum + sNum1; console.log(result + "," + srcMap[9]); return ((10 - result) == srcMap[9]); }