//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")){ $("#agentRightScope").val($("#agentCheckText").text()); }else{ $("#agentRightScope").val(""); } }); //被授權人 權利範圍 $("#rightCheckBox").click(function(){ if($(this).is(":checked")){ $("#rightScope").val($("#rightCheckText").text()); }else{ $("#rightScope").val(""); } }); 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); } }); //設定 畫面因表單不同所呈現字樣也不同(商標權人<=>著作權人) $(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=="WW907"){ $("#agentCheckText").html("包含向海關申請提示保護商標權案件相關事宜"); $("#rightCheckText").html("包含向海關申請提示保護商標權案件相關事宜"); } if(formId=="WW908"){ $("#agentCheckText").html("包含向海關申請延長提示保護商標權案件相關事宜"); $("#rightCheckText").html("包含向海關申請延長提示保護商標權案件相關事宜"); $("#agentUploadFile").html("委任書日期如有更動,請自行更新上傳代理人授權證明文件。"); } }); function checkField(){ //錯誤驗證 var formId=$("#formId").val(); var startDate=new Date($("input[name='wfapimmBean.startDate']").val()); //檢查權利存續期間(起迄 var endDate=new Date($("input[name='wfapimmBean.endDate']").val()); var protStartDate=new Date($("input[name='wfapimmBean.protStartDate']").val()); //檢查原核准之提示保護期間(起迄 WW905 WW906 var protEndDate=new Date($("input[name='wfapimmBean.protEndDate']").val()); var startIeDate = new Date($("input[name='wfapimmBean.startIeDate']").val()); //進出口日期(起迄) var endIeDate = new Date($("input[name='wfapimmBean.endIeDate']").val()); var agentStartDate = new Date($("input[name='wfapimmBean.agentStartDate']").val()); //代理人日期(起迄) var agentEndDate = new Date($("input[name='wfapimmBean.agentEndDate']").val()); var modifyDate = new Date($("input[name='wfapimmBean.modifyDate']").val()); //補正限制日期 var today = new Date(); 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 $agentLegalType1 = $("input[name='wfapimmBean.agentLegalType1']"); //代理人預設值為1的hidden欄位 var $agentIdno1 = $("input[name='wfapimmBean.agentIdno1']"); var msg=""; if(0==$("input[name='wfapimmBean.applyKind']:checked").length){ msg+="[請選擇申請人類別。]"; $('#statusMsg').val(msg).css("color","red"); return true; } //判斷申請人類別與應收送達人的關係 if(receiverTypeCheck()){ msg="[申請人類別(商標權人/專屬被授權人)與應收送達人選擇(商標權人/專屬被受權人不一致),請修正。]"; $('#statusMsg').val(msg).css("color","red"); return true; } if(checkReceiverType()){ msg+="[請點選 應受送達人]"; $('#statusMsg').val(msg).css("color","red"); return true; }else if(fieldIsEmpty()){ //必填欄位 msg="[請填寫有標記紅色背景及星號之欄位。]"; $('#statusMsg').val(msg).css("color","red"); return true; }else if(''!=$aplLegalType && checkEachIdno($aplLegalType,$aplIdno)){ msg+="[(申請人(商標權人)請填寫正確之統編/身分證號]"; }else if(''!=$liceLegalType && checkEachIdno($liceLegalType,$liceIdno)){ msg+="[(申請人(專屬被授權人)請填寫正確之統編/身分證號]"; }else if(''!=$agentLegalType && checkAgentIdno($agentLegalType,$agentIdno)){ msg+="[(1)代理人請填寫正確之統編/身分證號]"; }else if(''!=$agentLegalType1 && checkAgentIdno($agentLegalType1,$agentIdno1)){ msg+="[(2)代理人請填寫正確之統編/身分證號]"; }else if(checkCustomsNo()){ //檢查905 906 海關受理編號 msg+="[海關受理編號需大於或等於11碼!]"; }else if(checkCompanyId($("input[name='wfapimmBean.compBan']").val())){ //涉嫌侵權之進出口廠商統編 msg+="[請填寫正確 侵權之進出口廠商統編!]"; }else if(checkEmail()){ //檢查Email msg+="[電子信箱格式有誤!]"; }else if(checkDateFormat()){ //檢查日期格式 msg+="[日期格式有誤!]"; }else if(checkDate(startDate,endDate)){ //檢查權利存續期間(起迄 msg+="[權利存續日期起日不可大於迄日!]"; }else if(checkDate(protStartDate,protEndDate)){ //檢查原核准之提示保護期間(起迄 msg+="[原核准之提示保護期間起日不可大於迄日!]"; }else if(checkDate(startIeDate,endIeDate)){ //進出口日期(起迄) msg+="[進出口日期期間起日不可大於迄日!]"; }else if(checkDate(agentStartDate,agentEndDate)){ //代理人日期(起迄) msg+="[代理人日期期間起日不可大於迄日!]"; }else if(formId=='WW902' && regNoCheck($("input[name='wfapimmBean.regNo']").val())){ //商標註冊 msg+="[商標註冊號數必須為8碼]"; }else if(formId=='WW905' && regNoCheck($("input[name='wfapimmBean.orgRegNo']").val())){ //原商標註冊WW905 msg+="[原申請註冊號數必須為8碼]"; }else if(checkReceiverType()){ //補正限制日期 msg+="[請點選 應受送達人]"; }else if($("#status").val()==3&&checkDate(today,modifyDate)){ //補正限制日期 msg="[超過可補正時間,請重新申請]。"; } //檢核郵遞區號 if(checkAddr(formId) != ""){ msg += checkAddr(formId); } /*if(chkAddrCode(formId) != ""){ msg += chkAddrCode(formId); }*/ if(msg!=""){ $('#statusMsg').val(msg).css("color","red"); return true; }else{ return false; } } function checkIMinfo(){ var formId=$("#formId").val(); var msg=''; if('WW902'==formId || 'WW905'==formId){ if($('#'+formId+'_wfapimmBean_companyDesc').val().length>256){ msg=msg+'[被授權廠商或貿易商最大長度256個字!]' } if($('#'+formId+'_wfapimmBean_imExPath').val().length>256){ msg=msg+'[進/出口路徑最大長度256個字!]' } if($('#'+formId+'_wfapimmBean_brokerDesc').val().length>256){ msg=msg+'[進/出口貨物之運輸公司及報關行最大長度256個字!]' } if($('#'+formId+'_wfapimmBean_originGoods').val().length>64){ msg=msg+'[貨物原產地最大長度64個字!]' } if($('#'+formId+'_wfapimmBean_blacklist').val().length>256){ msg=msg+'[涉嫌輸出入仿冒品業者(黑名單)最大長度256個字!]' } if($('#'+formId+'_wfapimmBean_fakeImExMethod').val().length>256){ msg=msg+'[侵權品可能之進/出口方式(路徑、起運口岸…)最大長度256個字!]' } if($('#'+formId+'_wfapimmBean_fakeCountry').val().length>64){ msg=msg+'[侵權品可能生產國最大長度64個字!]' } } return msg; } 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; } } //以下檢查function為 未通過return true function fieldIsEmpty(){ // 必填欄位 var isEmpty=false; $("#abgne_tab, input[mustFill='must'], textarea[mustFill='must'] ").each(function( index ) { if($.trim($(this).val()).length!=0){ // 已填 $(this).css("background-color","rgb(196,211,255)"); }else{ // 未填 $(this).css("background-color",'#FF7573'); isEmpty=true; // 有一個未填就true } }); if(fieldSecondary()){ isEmpty=true; } return isEmpty; } /** * 依據應收送達人 決定該選取人之E-MAIL為必填 * */ /*function emailIsEmptyCheck(){ var formId=$("#formId").val(); 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)"); }); if('WW902'==formId || 'WW905'==formId){ $.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)"); }); if('WW902'==formId || 'WW905'==formId){ $.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"); }); if('WW902'==formId || 'WW905'==formId){ $.each($(".cont"),function(){ $(this).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); } break; case 4: $.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).removeAttr("mustFill").css("background-color","rgb(196,211,255)"); }); $.each($(".cont"),function(){ $(this).attr("mustFill","must"); }); break; } }*/ function fieldSecondary(){ var errorCount=0; var receiverType = $("input[name='wfapimmBean.receiverType']:checked").val(); //應收送達人 '1':'同商標權人','2':'同專屬被授權人','3':'同代理人','4':'送達代收人' switch(parseInt(receiverType)){ case 1: errorCount = checkReceiverType4Apl(); break; case 2: errorCount = checkReceiverType4Lice(); break; case 3: errorCount = checkReceiverType4Agent() + checkReceiverType4AgentCon_applyKind(); break; case 4: errorCount = checkReceiverType4Cont() + checkReceiverType4AgentCon_applyKind(); break; } if(errorCount>0){ return true; }else{ return false; } } function checkReceiverType4Apl(){ var errorCount = 0; var checkFields=['wfapimmBean.aplName', 'wfapimmBean.aplEname', 'wfapimmBean.aplAddr', 'wfapimmBean.aplEmail', 'wfapimmBean.aplTelNo', 'wfapimmBean.aplFaxNo']; $('.apl').css("background-color","rgb(196,211,255)"); return checkMustFieldByBeanName(checkFields); } function checkReceiverType4Lice(){ var errorCount = 0; var checkFields=['wfapimmBean.liceName', 'wfapimmBean.liceEname', 'wfapimmBean.liceAddr', 'wfapimmBean.liceEmail', 'wfapimmBean.liceTelNo', 'wfapimmBean.liceFaxNo', 'wfapimmBean.rightScope']; $.each($(".lice"),function(){ $(this).css("background-color","rgb(196,211,255)"); }); return checkMustFieldByBeanName(checkFields); } function checkReceiverType4Agent(){ var errorCount = 0; var checkFields=[]; if($("#agentDateType").prop("checked")==false){ checkFields=['wfapimmBean.agentLegalName', 'wfapimmBean.agentIdno', 'agentAddrCode', 'wfapimmBean.agentAddr', 'wfapimmBean.agentEmail', 'wfapimmBean.agentTelNo', 'wfapimmBean.agentFaxNo', 'wfapimmBean.agentStartDate', 'wfapimmBean.agentEndDate', 'wfapimmBean.agentRightScope']; } else { checkFields=['wfapimmBean.agentLegalName', 'wfapimmBean.agentIdno', 'agentAddrCode', 'wfapimmBean.agentAddr', 'wfapimmBean.agentEmail', 'wfapimmBean.agentTelNo', 'wfapimmBean.agentFaxNo', 'wfapimmBean.agentRightScope']; } $('.cont').css("background-color","rgb(196,211,255)"); return checkMustFieldByBeanName(checkFields); } function checkReceiverType4Cont(){ var errorCount = 0; var checkFields=['wfapimmBean.contName', 'contAddrCode', 'wfapimmBean.contAddr', 'wfapimmBean.contTelNo', 'wfapimmBean.contMobile', 'wfapimmBean.contEmail']; $('.agent').css("background-color","rgb(196,211,255)"); return checkMustFieldByBeanName(checkFields); } function checkReceiverType4AgentCon_applyKind(){ var applyKind = $("input[name='wfapimmBean.applyKind']:checked").val(); //申請人類別:1(商標權人) or 2(專屬被授權人) var checkFields; switch(parseInt(applyKind)){ case 1 : checkFields=['wfapimmBean.aplName', 'wfapimmBean.aplEname', 'wfapimmBean.aplLegalName', 'wfapimmBean.aplAddr']; $.each($(".apl"),function(){ $(this).css("background-color","rgb(196,211,255)"); }); $.each($(".lice"),function(){ $(this).val(""); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); break; case 2: checkFields=['wfapimmBean.liceName', 'wfapimmBean.liceEname', 'wfapimmBean.liceLegalName', 'wfapimmBean.liceAddr', 'wfapimmBean.rightScope']; $.each($(".lice"),function(){ $(this).css("background-color","rgb(196,211,255)"); }); $.each($(".apl"),function(){ $(this).val(""); $(this).attr('disabled', 'disabled'); $(this).css("background-color","#FEFFAF"); }); break; } return checkMustFieldByBeanName(checkFields) } function checkMustFieldByBeanName(arry_checkFields){ var errorCount = 0; for(var index in arry_checkFields){ var id = $("input[name='"+arry_checkFields[index]+"']"); if(''==id.val()){ errorCount++; id.css("background-color",'#FF7573'); }else{ id.css("background-color","rgb(196,211,255)"); } } return errorCount; } //應收送達人是否選擇 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 || regNo.length!=8){ //表單沒這個欄位或沒填值 return true; }else if(regNo.length==8){ 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()&&"WW907"!=$("#formId").val()){ //WW905 906 可不必上傳代理人 if(hasValue){ return 5; } } } /* * 回傳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為錯誤 } } } $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()))){ $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 limit(node){ //get the limit from maxlength attribute var limit = parseInt(node.attr('maxlength')); //get the current text inside the textarea var text = node.val(); //count the number of characters in the text var chars = text.length; //check if there are more characters then allowed if(chars > limit){ //and if there are use substr to get the text before the limit var new_text = text.substr(0, limit); //and change the current text with the new text node.val(new_text); } } /** * 依據申請人類別 決定該填寫商標權人/專屬被授權人 * */ function applyKindChage(){ applyKind = $("input[name='wfapimmBean.applyKind']:checked").val(); //申請人類別:1(商標權人) or 2(專屬被授權人) switch(parseInt(applyKind)){ case 1: var aplMustFields = ['wfapimmBean.aplName', 'wfapimmBean.aplEname', 'wfapimmBean.aplAddr', 'wfapimmBean.aplEmail', 'wfapimmBean.aplTelNo', 'wfapimmBean.aplFaxNo' ]; setApplyKind(aplMustFields,'.apl','.lice'); break; case 2: liceMustFields = ['wfapimmBean.liceName', 'wfapimmBean.liceEname', 'wfapimmBean.liceAddr', 'wfapimmBean.liceEmail', 'wfapimmBean.liceTelNo', 'wfapimmBean.liceFaxNo', 'wfapimmBean.rightScope']; setApplyKind(liceMustFields,'.lice','.apl'); 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"); }); } /** * 判斷申請人類別與應收送達人不同,顯示警示 * 主要是應收送達人選擇商標權/專屬被授權人但是與申請人類別不同,需要警告 * return true ,代表不一致 * */ function receiverTypeCheck(){ var formId=$("#formId").val(); applyKind = $("input[name='wfapimmBean.applyKind']:checked").val(); //申請人類別:1(商標權人) or 2(專屬被授權人) receiverType = $("input[name='wfapimmBean.receiverType']:checked").val(); //申請人類別:1(商標權人) or 2(專屬被授權人) if(formId=='WW902' || formId=='WW905'||formId=='WW907' || formId=='WW908') { //alert("receiverType="+receiverType); if (receiverType=='1' || receiverType=='2'){ if (applyKind!=receiverType){ return true; } else { return false; } } } return false; } //郵遞區號必填 function checkAddr(formId){ //var receiverType = $("input[name='wfapimmBean.receiverType']:checked").val(); var msg = ""; if(formId == "WW902" || formId == "WW905"){ //if(receiverType == 3){ //代理人 if( ($("#agentAddr").val() == '' && $("#agentAddrCode").val() != '') || ($("#agentAddr").val() != '' && $("#agentAddrCode").val() == '') ){ msg+="[代理人郵遞區號、地址欄位輸入不完全]"; $("#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)'); } //} else if(receiverType == 4){ //送達代收人 if( ($("#contAddr").val() == '' && $("#contAddrCode").val() != '') || ($("#contAddr").val() != '' && $("#contAddrCode").val() == '') ){ msg+="[送達代收人郵遞區號、地址欄位輸入不完全]"; $("#contAddrCode").css("background-color",'#FF7573'); $("#contAddr").css("background-color",'#FF7573'); }else{ $("#contAddr").css("background-color",'rgb(196,211,255)'); $("#contAddr").css("background-color",'rgb(196,211,255)'); } //} } return msg; } //郵遞區號長度 function chkAddrCode(formId){ var msg = ""; if(formId == "WW902" || formId == "WW905"){ //商標權人 if( $("#aplAddrCode").val() != '' && $("#aplAddr").val() != '' ){ if(!($("#aplAddrCode").val().length == 3 || $("#aplAddrCode").val().length == 5 || $("#aplAddrCode").val().length == 6 || $("#aplAddrCode").val().length == 15)){ msg+="[申請人(商標權人)郵遞區號必須為3碼、5碼、6碼或15碼數字]"; $("#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 || $("#liceAddrCode").val().length == 15)){ msg+="[申請人(專屬被授權人)郵遞區號必須為3碼、5碼、6碼或15碼數字]"; $("#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 || $("#agentAddrCode").val().length == 15)){ msg+="[代理人郵遞區號必須為3碼、5碼、6碼或15碼數字]"; $("#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)'); } //送達代收人 if( $("#contAddrCode").val() != '' && $("#contAddr").val() != '' ){ if(!($("#contAddrCode").val().length == 3 || $("#contAddrCode").val().length == 5 || $("#contAddrCode").val().length == 6 || $("#contAddrCode").val().length == 15)){ msg+="[送達代收人郵遞區號必須為3碼、5碼、6碼或15碼數字]"; $("#contAddrCode").css("background-color",'#FF7573'); }else{ $("#contAddrCode").css("background-color",'rgb(196,211,255)'); $("#contAddr").css("background-color",'rgb(196,211,255)'); } }else{ $("#contAddrCode").css("background-color",'rgb(196,211,255)'); $("#contAddr").css("background-color",'rgb(196,211,255)'); } } return msg; }