效果:
jsp页面:
版本号*版本名称*上传应用程序*下载地址*更新备注*
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: "必填", remote:"版本号重复", maxlength:"最大不能超过10位" }, 'versionName':{ required: "必填", remote:"版本名称重复", maxlength:"最大不能超过40位" }, 'updateLog':{ required: "必填", maxlength:"最大不能超过120位" } } }); }); });
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服务层
@Override public boolean validateversionCode(String versionCode){ int count = dbcAppVersionMapper.validateversionCode(versionCode); return (count>0)?false:true; } @Override public 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
关于bootstrap专题大家可以参考下:
bootstrap 组件
以上所述是小编给大家介绍的BootStrap框架下实现表单提交数据重复验证,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!