Ext.form.VTypes

1、为空验证的两个配置
allowBlank:false //false则不能为空,默认为true

blankText:string//当为空时的错误提示信息

items : [{
	fieldLabel : 'ENAME',
	name : 'emp.ename',
	allowBlank : false,
	blankText:"雇员姓名不能为空!"
}]

2、 用vtype格式的验证

        items: [{
                fieldLabel: 'Email',
                name: 'email',
                vtype:'email',
               vtypeText:"不是有效的邮箱地址"
       }]
form验证中vtype的默认支持类型:
a.alpha //只能输入字母,无法输入其他(如数字,特殊符号等)
b.alphanum//只能输入字母和数字,无法输入其他
c.email//email验证,要求的格式是"langsin@gmail.com"
d.url//url格式验证,要求的格式是[url]http://www.langsin.com[/url]

对应的正则表达式:

      alpha = /^[a-zA-Z_]+$/,
    alphanum = /^[a-zA-Z0-9_]+$/,
    email = /^(\w+)([\-+.\'][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/,
    url = /(((^https?)|(^ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;


3、自定义验证

// custom Vtype for vtype:'time'
var timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
Ext.apply(Ext.form.VTypes, {
    //  vtype validation function
    time: function(val, field) {
        return timeTest.test(val);
    },
    // vtype Text property: The error text to display when the validation function returns false
    timeText: 'Not a valid time.  Must be in the format "12:34 PM".',
    // vtype Mask property: The keystroke filter mask
    timeMask: /[\d\s:amp]/i
});

Ext.form.VTypesPublic Properties

Property Defined By
alphaMask: RegExp
The keystroke filter mask to be applied on alpha input. Defaults to: /[a-z_]/i
VTypes
alphanumMask: RegExp
The keystroke filter mask to be applied on alphanumeric input. Defaults to: /[a-z0-9_]/i
VTypes


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值