form表单里,当输入项为必填项时,需要将对应item的allowblank属性设置为true,如果item的label后面自带红色的*,表单中哪些输入项是“必填”,哪些输入项是“非必填”,一眼望去清晰明了,对用户来说会更加友好。

将下面的代码,放在页面js代码中Ext.onReady的前面,页面里的必填项的label后面会自带红色的*

代码如下:

/*
 重写allowBank的属性配置
 */
Ext.override(Ext.form.field.Base, {
    initComponent: function () {
        if (this.allowBlank !== undefined && !this.allowBlank) {
            if (this.fieldLabel) {
                this.fieldLabel += '<font color=red>*</font>';
            }
        }
        this.callParent(arguments);
    }
});

 效果图:

ext当表单中的输入项为必填时,输入项label后显示红色的*

 

相关文章:

  • 2021-04-07
  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2021-11-08
  • 2021-12-30
  • 2022-12-23
  • 2021-05-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
  • 2021-05-14
  • 2021-10-09
  • 2022-12-23
相关资源
相似解决方案