accountName: { validator: function (value,param) { if (!/^[a-zA-Z][a-zA-Z0-9_]{3,15}$/i.test(value)) { $.fn.validateBox.defaults.rules.accountName.message = '账户名称不合法(字母开头,允许4-16字节,允许字母数字下划线)'; return false; } else { var postdata = {}; postdata[param[1]] = value; var result = $.ajax({ url: param[0],data: postdata,type: 'post',dataType: 'json',async: false,cache: false }).responseText; if (result == 'false') { $.fn.validateBox.defaults.rules.accountName.message = '账户名称已存在!'; return false; } else { return true; } } },message: '' },
HTML
<input required="true" missingMessage="账户名称不能为空!" validType="accountName['checkAccountNameUnique.html','account']" class="easyui-validateBox" type="text" name="account" style="width: 190px;"/>原文链接:https://www.f2er.com/ajax/165304.html