1. 程式人生 > >ext ajax validator全表單字段重復校驗處理

ext ajax validator全表單字段重復校驗處理

urn .get req 全局 lur 檢驗 pat info return

定義全局檢驗函數


basedev.baseSite.uniqueSiteName=function(field){
if(!field){
return true;
}

var editBaseSiteInfoForm = Ext.getCmp(basedev.baseSite.EDIT_BASE_SITE_FORM_ID);

var siteCode = editBaseSiteInfoForm.getForm().findField("siteCode").getValue();
var paramsObj = {siteCode : siteCode, siteName : field, state : editBaseSiteInfoForm.getOperatorType()};

var valid = false; Ext.Ajax.request({ url : basedev.realPath(‘uniqueCheckBySiteName.do‘), params: paramsObj, async : false, success : function(response) { var result = Ext.JSON.decode(response.responseText); if(result.success){ if(result.data == 0){ valid = true; } }else{ Ext.ux.Toast.msg(‘提示‘, result.msg); } }, failure :
function(response) { Ext.ux.Toast.msg(‘提示‘,response.responseText, ‘error‘); } }); if(valid){ return true; } return ‘該門店名稱已存在‘; };
控件使用blur替代 validator listeners:{
‘blur‘:function(field){ var uniqueSiteName = basedev.baseSite.uniqueSiteName(field.rawValue); if(uniqueSiteName!=true) { field.markInvalid(uniqueSiteName); } } }
/*****************提交表單時ajax校驗再走一次 start*****************/ var uniqueSiteName=basedev.baseSite.uniqueSiteName(baseSiteForm.findField(‘siteName‘).getValue()); if(uniqueSiteName!=true){ baseSiteForm.findField(‘siteName‘).markInvalid(uniqueSiteName); return; }/*****************提交表單時ajax校驗再走一次 end*****************/

ext ajax validator全表單字段重復校驗處理