ExtJS provides us with a complete form verification function, so that we can easily achieve a variety of form field verification, which is a little more complex password verification, today, Lee Bad on ExtJS password verification function for everyone to provide a simple demo, I hope to help.
Password authentication consists of two main elements:
1. Whether the combination of passwords meets the requirements (for example, whether it is an alphanumeric combination, etc.);
2. Two incoming passwords are consistent
The code is as follows:
| The code is as follows |
Copy Code |
| Ext.application ({ Name: ' Demo ', Appfolder: ' App ', Launch:function () { Ext.create (' Ext.container.Viewport ', { Margin: ' 100 0 0 200 ', items:[{ Xtype: ' Form ', Title: ' Password verification ', HEIGHT:500, width:700, defaults:{ Xtype: ' TextField ', WIDTH:300, Labelwidth:60, Margin: ' 20 0 0 200 ', InputType: ' Password ', Allowblank:false, Msgtarget: ' under ' }, items:[{ Fieldlabel: ' Enter password ', Regex:/^ ([A-za-z0-9]{6,}) $/i, Regextext: ' Password must contain both letters and numbers, with at least 6 digits ' },{ Fieldlabel: ' Enter again ', Validator:function (value) { var pw = this.previoussibling (). value; if (value!= pw) { Return ' two input passwords inconsistent '; }else{ return true; } } }] }] }); } }); |
Description
1. The first time you enter a password, the regular expression to verify that the password is legitimate (you can write your own regular expression according to the actual situation)
2. The second input password, through the validator validator, to determine whether the input is consistent with the last