ExtJs form validation Methods

First, the basic authentication using vtype property.

1.alpha only letters, you can not enter the other (such as numbers, special characters, etc.)

2.alphanum only letters and numbers, you can not enter another

3.email verification is required format [email protected]

4.url format validation, the required format http://www.baidu.com

Second, verify in other ways.

1. Verify that the maximum and minimum input words.

1 maxLength : 20,//允许输入的最大字符数
2 maxLengthText : "用户帐号最大长度不能超过20个字符!",//提示文本
3 minLength : 3, //允许输入的最少字符数
4 minLengthText : "用户帐号最小长度不能少于3个字符!",//提示文本

Note: Chinese characters instead of two characters, such as "hello" count two characters.

2. The regular expression validation.

1 regex : /^(([0-9]+[a-zA-Z]+)|([a-zA-Z]+[0-9]+))$/,
2 regexText : "对不起,用户帐号只能输入字母和数字!",

Three, vtype for advanced verification.

Because of vtype Extjs only achieve four basic authentication, all need their own to create a new authentication method.

When added to the form code after initialization

1 Ext.apply(Ext.form.VTypes, {
2 verifycustomer : function(value) {//验证方法名
3 //验证方法
4 }
5 });

vtype property of the control to a custom validation method name and hint text vtypeText property.

1 vtype : "verifycustomer",
2 vtypeText : "对不起,客户账号已经存在!",

 

Reproduced in: https: //my.oschina.net/weisenz/blog/200619

Guess you like

Origin blog.csdn.net/weixin_34315189/article/details/91920881