2012-05-29 30 views
0

我正在为需要验证的表单创建模型。sencha的数据验证

这个模型看起来是这样的:

//Defining a data structure for the Work Item List 
Ext.define('InfoImage.model.configure.configModel', { 
    extend : 'Ext.data.Model', 

    config : { 
     //Defining the fields required in the Work Item List 
     fields : [ 'servname', 'port', 'protocol', 'username', 'password', 
       'domain', 'appconfig', 'apptitle', 
       'appconfig' ], 

     validations : [ 
     { 
      type : 'presence', 
      name : 'servname' 
     }, 
     { 
      type : 'presence', 
      name : 'port' 
     // matcher : /[0-9]{4}[A-Z]+/ 
     }, 
     { 
      type : 'presence', 
      name : 'username' 
     }, 
     { 
      type : 'presence', 
      name : 'password' 
     }], 
     proxy : { 
      type : 'localstorage', 
      id : 'configId' 
     } 
    } 
}); 

我试图通过

Ext.getCmp('form').validate(); 

调用验证,但它说,它没有所谓的验证方法。

sencha是否提供验证方法?如果是的话,我该如何实现它?

回答