温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

jQuery插进 tooltip提示和validate

发布时间:2020-06-02 07:28:41 来源:网络 阅读:2615 作者:zhangminonly 栏目:web开发

 

  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. //上传景点图片 
  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. //删除景点图片 
  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="日程天数,正整数" id="scheduleDay"  name="scheduleDay" maxlength="2" class="text_30" />'
  145.     strHtml += '日</td><td align="right" width="70px">观光内容:</td><td width="222px">'
  146.     strHtml += '<textarea class="textarea_300_50" style="width: 220px;" title="观光内容的介绍,0-250个字符" 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个字符" 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. //验证日程 
  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问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI