Ext:TextField 后台验证名称是否重复

来源:互联网 发布:mac 设置分辨率 编辑:程序博客网 时间:2024/06/05 02:14

// 登录名称
 var loginNameTxt = new Ext.form.TextField({
    fieldLabel : "登录帐号",
    name : "wytUser.loginName",
    width : 250,
    allowBlank : false,
    blankText : "帐号不能为空!",
    emptyText : "请输入登录帐号",
    invalidText : '登录账号已存在!',
    minLength : 1,
    maxLength : 16,
    maxLengthText : "帐号长度1-16位.",
    minLengthText : "帐号长度1-16位.",
    validationEvent : 'blur',
    validator : function(thisText) {
     var isok = false;
     if (thisText == "") {
      return true;
     }
     Ext.Ajax.request({
        url : Action.sys.UserMngAction.DO_VALI_LOGINNAME,
        params : {
         "wytUser.loginName" : thisText,
         "wytUser.id" : 0
        },
        async : false,
        method : 'POST',
        success : function(response, options) {
         var res = Ext.util.JSON
           .decode(response.responseText);
         if (res.success == true) {
          isok = true;
         } else {
          isok = false;
         }
        }
       });
     return isok;
    }
   })