声明:我这个是html页面,vue原理相同
需求是课题名称唯一,不可以重复名称录入
原有方法要输入全部信息点击添加按钮进行ajax后台验证是否课题名称存在,必要烦人,用户体验很差,操作繁琐
现在使用鼠标点击时间当鼠标移出课题字段输入框进行后台验证,比较快捷
方法步骤:
字段展示正常写
<tr>
<th><font color="red">*</font>名称:</th>
<td><input maxlength="50" class="span3" field="LIBRARY_NAME" type="text"
id="LIBRARY_NAME" name="LIBRARY_NAME" datatype="*" nullmsg="此项不能为空" sucmsg=" ">
<div class="Validform_checktip"></div></td>
<th><font color="red">*</font>方案类别:</th>
鼠标点击方法验证,返回弹出提示
$(document).ready(function() {
$("#LIBRARY_NAME").mouseout(function() {
var LIBRARY_NAME = $("#LIBRARY_NAME").val();
var checkMonth = false;
$.ajax({
type: 'GET',
url: '${root!}/technology/findByXm?LIBRARY_NAME='+LIBRARY_NAME,
async: false,
success: function (data) {
if (data.length != 0){
Power.dialog.alertError("此名称已经存在!");
}else {
checkMonth = true;
}
}
})
});
});