How to dynamically change textfield maxLength

By Vitaliy on March 20, 2012. ExtJS 4.0.7
3357
Reply to thread

Js Code

Ext.widget('form', {
	title: 'Test Form',
	width: 300,
	bodyPadding: 10,
	renderTo: 'output',
	items: [
		{
			xtype: 'textfield',
			name: 'UserName',
			fieldLabel: 'UserName',
			maxLength: 4,
			enforceMaxLength: true
		}
	],
	buttons: [
		{
			text: 'Increment MaxLength',
			handler: function () {
				var form = this.up('form');
				var textfield = form.down('textfield[name=UserName]');
				textfield.maxLength += 2;
				textfield.inputEl.dom.maxLength += 2;
			}
		}
	]
});