国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

BootStrap+Mybatis框架下實現表單提交數據重復驗證

2019-11-19 17:03:37
字體:
來源:轉載
供稿:網友

效果:


jsp頁面:

<form class="form-horizontal lui-tj-bd" id="dbc_code_add_form" method="post"><div class="row"><div class="col-xs-12"><!-- PAGE CONTENT BEGINS --><div class="tabbable"><div class="space-12"></div><div class="profile-user-info profile-user-info-striped"><div class="profile-info-row"><div class="profile-info-name" > 版本號<font color="red">*</font></div><div class="profile-info-value"><input type="hidden" value="${list.id}" name="id" class="col-xs-12 col-sm-9" /><input type="hidden" value="${list.versionCode}" id="oldversionCode" name="oldversionCode" class="col-xs-12 col-sm-9" /><input type="text" value="${list.versionCode}" id="versionCode" name="versionCode" class="col-xs-12 col-sm-9" /></div></div><div class="profile-info-row"><div class="profile-info-name" > 版本名稱<font color="red">*</font></div><div class="profile-info-value"><input type="hidden" value="${list.versionName}" id="oldversionName" name="oldversionName" class="col-xs-12 col-sm-9" /><input type="text" value="${list.versionName}" id="versionName" name="versionName" class="col-xs-12 col-sm-9"/></div></div><div class="profile-info-row"><div class="profile-info-name" > 上傳應用程序<font color="red">*</font></div><div class="profile-info-value"><input type="file" name="file_upload" id="file_upload" /></div></div><div class="profile-info-row "><div class="profile-info-name"> 下載地址<font color="red">*</font> </div><div class="profile-info-value"><span class="editable editable-click"><input type="text" id="downloadUrl" name="downloadUrl" class="col-xs-12 col-sm-9" readonly="readonly" value="${list.downloadUrl}" /></span></div></div><div class="profile-info-row"><div class="profile-info-name" > 更新備注<font color="red">*</font></div><div class="profile-info-value"><textarea class="col-sm-9 col-xs-12 " rows="5" id="updateLog" name="updateLog" >${list.updateLog}</textarea></div></div></div><div class="space-24"></div><div><div class=" col-md-offset-2 col-md-9 col-xs-12"><div class=" col-xs-6"><button class="btn btn-sm btn-success" type="button" id="saveButton2" style="float:right;" onclick="tobaocun()"><i class="ace-icon fa fa-check "></i>保存</button></div><button class="btn btn-sm btn-purple" type="reset"><i class="ace-icon fa fa-undo "></i> 重置</button></div></div></div></div></div></form>

js:

ace.load_ajax_scripts(scripts, function () { jQuery(function ($) { //驗證  $("#dbc_code_add_form").validate({ rules: { 'versionCode': { required: true, maxlength:20,  remote:{ type:"post", dataType:"json", data:{versionCode:function () { return $("#versionCode").val();}, oldversionCode:function () { return $("#oldversionCode").val();} }, url:"${base}/admin/road/app/validateversionCode.do"   } }, 'versionName': { required: true, maxlength:40, remote:{ type:"post", dataType:"json", data:{versionName:function () { return $("#versionName").val();}, oldversionName:function () { return $("#oldversionName").val();} }, url:"${base}/admin/road/app/validateversionName.do"   } }, 'updateLog': { required: true, maxlength:125 } }, messages:{ 'versionCode':{ required: "<font color='#d16e6c'>必填</font>", remote:"<font color='#d16e6c'>版本號重復</font>", maxlength:"<font color='#d16e6c'>最大不能超過10位</font>" }, 'versionName':{ required: "<font color='#d16e6c'>必填</font>", remote:"<font color='#d16e6c'>版本名稱重復</font>", maxlength:"<font color='#d16e6c'>最大不能超過40位</font>" }, 'updateLog':{ required: "<font color='#d16e6c'>必填</font>", maxlength:"<font color='#d16e6c'>最大不能超過120位</font>" } } }); });});

controller控制層:

@RequestMapping(value="/validateversionCode",method=RequestMethod.POST) @ResponseBody public boolean validateversionCode(@RequestParam("versionCode")String versionCode, @RequestParam("oldversionCode")String oldversionCode){ if(!versionCode.equals(oldversionCode)||StringUtils.isEmpty(oldversionCode)){ boolean isOk = appversionService.validateversionCode(versionCode); return isOk; } return true; }
@RequestMapping(value="/validateversionName",method=RequestMethod.POST) @ResponseBody public boolean validateversionName(@RequestParam("versionName")String versionName, @RequestParam("oldversionName")String oldversionName){ if(!versionName.equals(oldversionName)||StringUtils.isEmpty(oldversionName)){ boolean isOk = appversionService.validateversionName(versionName); return isOk; } return true; }

service服務層

@Overridepublic boolean validateversionCode(String versionCode){int count = dbcAppVersionMapper.validateversionCode(versionCode);return (count>0)?false:true;}@Overridepublic boolean validateversionName(String versionName){int count = dbcAppVersionMapper.validateversionName(versionName);return (count>0)?false:true;}

dao 層

int validateversionCode(@Param("versionCode")String versionCode);int validateversionName(@Param("versionName")String versionName);

mapper.xml

<!-- APP版本名稱驗證--> <select id="validateversionName" resultType="java.lang.Integer">select count(id)from dbc_app_versionwhere VERSION_NAME=#{versionName}</select><!-- APP版本號驗證--> <select id="validateversionCode" resultType="java.lang.Integer">select count(id)from dbc_app_versionwhere VERSION_CODE=#{versionCode}</select>

關于bootstrap專題大家可以參考下:

bootstrap 組件

以上所述是小編給大家介紹的BootStrap框架下實現表單提交數據重復驗證,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 洪洞县| 兖州市| 连州市| 龙州县| 工布江达县| 万州区| 平武县| 阿拉善左旗| 河津市| 永昌县| 浦城县| 万载县| 波密县| 宾阳县| 锦屏县| 南充市| 潜山县| 广东省| 定安县| 屏南县| 白水县| 洱源县| 临湘市| 凤台县| 和田县| 建始县| 舟曲县| 游戏| 淮南市| 和平县| 永寿县| 白银市| 宜宾县| 宁安市| 常州市| 扎兰屯市| 酉阳| 上高县| 宁远县| 邵东县| 沐川县|