如何在Extjs6中验证文本?以及添加代码的位置?

时间:2016-10-24 20:40:17

标签: extjs6

我正在关注Extjs中的教程,我有这个观点(YourTurn.js)

class Player(models.Model):
    name = models.CharField(max_length=50)
    photo = models.ImageField()
    games = models.IntegerField()
    minutes = models.IntegerField()
    points = models.IntegerField()
    assists = models.IntegerField()
    rebounds = models.IntegerField()
    steals = models.IntegerField()

    def __unicode__(self):
        return self.name

我有这个视图的控制器(YourTurnController.JS):

let counter = 0;

if (window.localStorage.getItem('counter') === null) {
  setInterval(
    () => {
      document.body.innerText = counter;
      window.localStorage.setItem('counter', counter)
      counter++
    },
    1000
  )
} else {
  window.addEventListener('storage', event => {
    document.body.innerText = event.newValue;
  })
}

它应该验证文本字段的输入值应该在0-9之间,小写和大写字母..等等,但是它没有工作我在浏览器(chrome)中出现了这个错误:

Ext.define('Student.view.main.YourTurn', {
  extend: 'Ext.window.Window',
  xtype: 'mainyour',

  requires: [
    'Student.view.main.YourTurnController',
    'Ext.form.Panel'
  ],

  autoShow: true,
  height: 170,
  width: 360,
  layout: {
    type: 'fit'
  },
  iconCls: 'key',
  title: "Login",
  closeAction: 'hide',
  closable: false,
  items: [{
    xtype: 'form',
    frame: false,
    bodyPadding: 15,
    defaults: {
      xtype: 'textfield',
      anchor: '100%',
      labelWidth: 60
    },
    items: [{
      name: 'user',
      fieldLabel: "User",
      allowBlank:false,
      vtype:'alphanum',
      minLenght:3,
      msgTarget:'under',

    }, {
      inputType: 'password',
      name: 'password',
      fieldLabel: "Password",
      maxLength:15,
      allowBlank:false,
      vtype:'alphanum',
      minLenght:3,
      msgTarget:'under',

    }]
  }]



}); 

请任何人帮我解释我做错了什么?

1 个答案:

答案 0 :(得分:0)

您应该考虑使用侦听器来验证密码的输入类型。

尝试使用此链接指向更改侦听器的文档:

http://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Text.html#event-change