溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

jQuery插進(jìn) tooltip提示和validate

發(fā)布時(shí)間:2020-06-02 07:28:41 來源:網(wǎng)絡(luò) 閱讀:2616 作者:zhangminonly 欄目:web開發(fā)

 

  1. <script type="text/javascript" src="<%=path%>/common/js/jquery.tipsy.js"></script> 
  2.     <script type="text/javascript" src="<%=path%>/common/js/jquery.validate.js"></script> 

validate.js

 

  1. function AddAbroadTravel(){} 
  2.  
  3. $().ready(function() { 
  4.     $("#abroadtravelForm").validate({ 
  5.         submitHandler:function(form){ 
  6.             if(!AddAbroadTravel.validateSchedule()){ 
  7.                 return
  8.             } 
  9.             var form = document.getElementById("abroadtravelForm"); 
  10.             form.encding="application/x-www-form-urlencoded"
  11.             form.action = "/admin/abroadTravelAction!showAbroadTravel"
  12.             form.target = "_self"
  13.             form.submit(); 
  14.         }, 
  15.         rules: { 
  16.             "info.travelName": { 
  17.                 required: true
  18.                 minlength: 2, 
  19.                 maxlength: 100 
  20.             }, 
  21.             "info.travelDeparture": { 
  22.                 required: true 
  23.             }, 
  24.             "info.travelDestin": { 
  25.                 required: true 
  26.             }, 
  27.             "info.travelRoomUsers": { 
  28.                 required: false
  29.                 digits:true 
  30.             }, 
  31.             "info.travelOnePersonRoom": { 
  32.                 minlength: 0, 
  33.                 maxlength: 100 
  34.             }, 
  35.             "info.travelDiningViews": { 
  36.                 required: false
  37.                 minlength: 0, 
  38.                 maxlength: 25 
  39.             }, 
  40.             "info.travelHotel": { 
  41.                 required: false
  42.                 minlength: 0, 
  43.                 maxlength: 50 
  44.             }, 
  45.             "info.travelTouristGuide": { 
  46.                 required: false
  47.                 minlength: 0, 
  48.                 maxlength: 50 
  49.             }, 
  50.             "info.travelConditions": { 
  51.                 required: false
  52.                 minlength: 0, 
  53.                 maxlength: 50 
  54.             }, 
  55.             "info.travelPeriod": { 
  56.                 required: true
  57.                 digits:true 
  58.             }, 
  59.             "info.travelAccomCity": { 
  60.                 required: false
  61.                 minlength: 0, 
  62.                 maxlength: 50 
  63.             }, 
  64.             "info.travelFuelCosts": { 
  65.                 required: false
  66.                 minlength: 0, 
  67.                 maxlength: 250 
  68.             }, 
  69.             "info.travelLocalTax": { 
  70.                 required: false
  71.                 minlength: 0, 
  72.                 maxlength: 250 
  73.             }, 
  74.             "info.travelAirportConstrFee": { 
  75.                 required: false
  76.                 minlength: 0, 
  77.                 maxlength: 250 
  78.             }, 
  79.             "info.travelChildrenPrice": { 
  80.                 required: false
  81.                 minlength: 0, 
  82.                 maxlength: 250 
  83.             }, 
  84.             "info.travelPoints": { 
  85.                 required: false
  86.                 minlength: 0, 
  87.                 maxlength: 250 
  88.             }, 
  89.             "info.travelOtherOptions": { 
  90.                 required: false
  91.                 minlength: 0, 
  92.                 maxlength: 250 
  93.             }, 
  94.             "info.travelNotes": { 
  95.                 required: false
  96.                 minlength: 0, 
  97.                 maxlength: 250 
  98.             }, 
  99.             "info.travelCommitment": { 
  100.                 required: false
  101.                 minlength: 0, 
  102.                 maxlength: 250 
  103.             }, 
  104.             "info.travelDepaTime": { 
  105.                 required: true 
  106.             } 
  107.         } 
  108.     }); 
  109.     var initTravelDeparture = jQuery("#initTravelDeparture").val(); 
  110.     var initTravelDestin = jQuery("#initTravelDestin").val(); 
  111.      
  112.     if(!initTravelDeparture) 
  113.         initTravelDeparture = ""
  114.          
  115.     if(!initTravelDestin) 
  116.         initTravelDestin = ""
  117.          
  118.     linkage.init('travelDeparture_select_country','travelDeparture_select_city',initTravelDeparture); 
  119.     linkage.init('travelDestin_select_country','travelDestin_select_city',initTravelDestin); 
  120.  
  121. }); 
  122.  
  123. //上傳景點(diǎn)圖片 
  124. AddAbroadTravel.uploadImg = function(){ 
  125.     var imgPath = jQuery("#upload").val(); 
  126.     if(imgPath){ 
  127.         var form = document.getElementById("abroadtravelForm"); 
  128.         form.encding="multipart/form-data"
  129.         form.action = "/admin/abroadTravelImgAction"
  130.         form.target = "uploadImgFrame"
  131.         form.submit(); 
  132.     } 
  133. }; 
  134.  
  135. //刪除景點(diǎn)圖片 
  136. AddAbroadTravel.delImg = function(imgA){ 
  137.     jQuery(imgA.parentNode.parentNode).remove(); 
  138. }; 
  139.  
  140. //追加日程 
  141. AddAbroadTravel.addSchedule = function(){ 
  142.     var imgsTables = document.getElementById("scheduleTable"); 
  143.     var tr = imgsTables.insertRow(imgsTables.rows.length); 
  144.     var strHtml = '<td width="70px">第<input type="text" title="日程天數(shù),正整數(shù)" id="scheduleDay"  name="scheduleDay" maxlength="2" class="text_30" />'
  145.     strHtml += '日</td><td align="right" width="70px">觀光內(nèi)容:</td><td width="222px">'
  146.     strHtml += '<textarea class="textarea_300_50" style="width: 220px;" title="觀光內(nèi)容的介紹,0-250個(gè)字符" id="scheduleContent" name="scheduleContent"></textarea>'
  147.     strHtml += ' </td><td align="right" width="70px">居住酒店:</td>'
  148.     strHtml += ' <td><input type="text" id="scheduleHotels" title="居住的酒店名稱,2-100個(gè)字符" name="scheduleHotels" maxlength="100" class="text_120" /> '
  149.     strHtml += '<a href="JavaScript:void(0)" onclick="AddAbroadTravel.delSchedule(this)">X</a></td>'
  150.     tr.innerHTML = strHtml; 
  151.     jQuery('#div2 [title]').tipsy({trigger: 'focus',fade: true}); 
  152. }; 
  153.  
  154. //刪除日程 
  155. AddAbroadTravel.delSchedule = function(obj){ 
  156.     jQuery(obj.parentNode.parentNode).remove(); 
  157. }; 
  158.  
  159. //驗(yàn)證日程 
  160. AddAbroadTravel.validateSchedule = function(){ 
  161.     var scheduleDays = jQuery("input[name='scheduleDay']"); 
  162.     var scheduleContents = jQuery("textarea[name='scheduleContent']"); 
  163.     var scheduleHotels = jQuery("input[name='scheduleHotels']"); 
  164.  
  165.     var i = 0; 
  166.     for(i = 0; i < scheduleDays.length; i++){ 
  167.         if(!FM.STRING.isNum(jQuery(scheduleDays[i]).val())){ 
  168.             jQuery(scheduleDays[i]).focus(); 
  169.             return false
  170.         } 
  171.     } 
  172.  
  173.     for(i = 0; i < scheduleContents.length; i++){ 
  174.         if(jQuery(scheduleContents[i]).val().length > 250){ 
  175.             jQuery(scheduleContents[i]).focus(); 
  176.             return false
  177.         } 
  178.     } 
  179.      
  180.     for(i = 0; i < scheduleHotels.length; i++){ 
  181.         if(jQuery(scheduleHotels[i]).val().length > 100){ 
  182.             jQuery(scheduleHotels[i]).focus(); 
  183.             return false
  184.         } 
  185.     } 
  186.     return true
  187. }; 

 

附件:http://down.51cto.com/data/2358358
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI