继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

jQuery插进 tooltip提示和validate

Qyou
关注TA
已关注
手记 255
粉丝 52
获赞 361

 

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

validate.js

 

function AddAbroadTravel(){}  $().ready(function() {     $("#abroadtravelForm").validate({         submitHandler:function(form){             if(!AddAbroadTravel.validateSchedule()){                 return;             }             var form = document.getElementById("abroadtravelForm");             form.encding="application/x-www-form-urlencoded";             form.action = "/admin/abroadTravelAction!showAbroadTravel";             form.target = "_self";             form.submit();         },         rules: {             "info.travelName": {                 required: true,                 minlength: 2,                 maxlength: 100             },             "info.travelDeparture": {                 required: true             },             "info.travelDestin": {                 required: true             },             "info.travelRoomUsers": {                 required: false,                 digits:true             },             "info.travelOnePersonRoom": {                 minlength: 0,                 maxlength: 100             },             "info.travelDiningViews": {                 required: false,                 minlength: 0,                 maxlength: 25             },             "info.travelHotel": {                 required: false,                 minlength: 0,                 maxlength: 50             },             "info.travelTouristGuide": {                 required: false,                 minlength: 0,                 maxlength: 50             },             "info.travelConditions": {                 required: false,                 minlength: 0,                 maxlength: 50             },             "info.travelPeriod": {                 required: true,                 digits:true             },             "info.travelAccomCity": {                 required: false,                 minlength: 0,                 maxlength: 50             },             "info.travelFuelCosts": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelLocalTax": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelAirportConstrFee": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelChildrenPrice": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelPoints": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelOtherOptions": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelNotes": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelCommitment": {                 required: false,                 minlength: 0,                 maxlength: 250             },             "info.travelDepaTime": {                 required: true             }         }     });     var initTravelDeparture = jQuery("#initTravelDeparture").val();     var initTravelDestin = jQuery("#initTravelDestin").val();          if(!initTravelDeparture)         initTravelDeparture = "";              if(!initTravelDestin)         initTravelDestin = "";              linkage.init('travelDeparture_select_country','travelDeparture_select_city',initTravelDeparture);     linkage.init('travelDestin_select_country','travelDestin_select_city',initTravelDestin);  });  //上传景点图片 AddAbroadTravel.uploadImg = function(){     var imgPath = jQuery("#upload").val();     if(imgPath){         var form = document.getElementById("abroadtravelForm");         form.encding="multipart/form-data";         form.action = "/admin/abroadTravelImgAction";         form.target = "uploadImgFrame";         form.submit();     } };  //删除景点图片 AddAbroadTravel.delImg = function(imgA){     jQuery(imgA.parentNode.parentNode).remove(); };  //追加日程 AddAbroadTravel.addSchedule = function(){     var imgsTables = document.getElementById("scheduleTable");     var tr = imgsTables.insertRow(imgsTables.rows.length);     var strHtml = '<td width="70px">第<input type="text" title="日程天数,正整数" id="scheduleDay"  name="scheduleDay" maxlength="2" class="text_30" />';     strHtml += '日</td><td align="right" width="70px">观光内容:</td><td width="222px">';     strHtml += '<textarea class="textarea_300_50"  title="观光内容的介绍,0-250个字符" id="scheduleContent" name="scheduleContent"></textarea>';     strHtml += ' </td><td align="right" width="70px">居住酒店:</td>';     strHtml += ' <td><input type="text" id="scheduleHotels" title="居住的酒店名称,2-100个字符" name="scheduleHotels" maxlength="100" class="text_120" /> ';     strHtml += '<a href="JavaScript:void(0)" onclick="AddAbroadTravel.delSchedule(this)">X</a></td>';     tr.innerHTML = strHtml;     jQuery('#div2 [title]').tipsy({trigger: 'focus',fade: true}); };  //删除日程 AddAbroadTravel.delSchedule = function(obj){     jQuery(obj.parentNode.parentNode).remove(); };  //验证日程 AddAbroadTravel.validateSchedule = function(){     var scheduleDays = jQuery("input[name='scheduleDay']");     var scheduleContents = jQuery("textarea[name='scheduleContent']");     var scheduleHotels = jQuery("input[name='scheduleHotels']");      var i = 0;     for(i = 0; i < scheduleDays.length; i++){         if(!FM.STRING.isNum(jQuery(scheduleDays[i]).val())){             jQuery(scheduleDays[i]).focus();             return false;         }     }      for(i = 0; i < scheduleContents.length; i++){         if(jQuery(scheduleContents[i]).val().length > 250){             jQuery(scheduleContents[i]).focus();             return false;         }     }          for(i = 0; i < scheduleHotels.length; i++){         if(jQuery(scheduleHotels[i]).val().length > 100){             jQuery(scheduleHotels[i]).focus();             return false;         }     }     return true; };

 

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP