ExtJs 4: password validation + random password button

This one is simple.

Feel free to replace the regular expression with your own. Mine is very basic.

Ext.apply(Ext.form.field.VTypes, {
	password: function(val, field) {
		if (/^[a-z0-9]+$/i.test(val)) {
			return true;
		}
	},
	passwordText: 'Password may only contain letters and numbers.'
});

Then add vtype: 'password' to properties of the password textfield:

{
	xtype: 'textfield',
	...
	vtype: 'password',
	minLength: 4,
	maxLength: 32,
	allowBlank: false
	...
}

You can see it in action in the demo together with the random password button.

This entry was posted in Programming and tagged , . Bookmark the permalink.

One Response to ExtJs 4: password validation + random password button

  1. Pingback: Ext.form « Programming Learning

Leave a Reply

Your email address will not be published. Required fields are marked *