PDA

View Full Version : TextArea enforceMaxLength and maxLength not working in IE with key ("x", "c", "v")



Romick
25 Jan 2013, 1:43 AM
Hi!
I have a problem. In IE I when set textArea.maxLength = 3, but I can enter more than 3 key such as ("x", "c", "v") is it a bug? Below is my test case:


Ext.MessageBox.textArea.enforceMaxLength = true;
Ext.MessageBox.textArea.maxLength = 3;
Ext.MessageBox.show({
title: 'enforceMaxLength and maxLength Not Work in IE with key ("x", "c", "v") you can input as much as you want!',
msg: 'Please enter 3 letter word',
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
modal: true,
value: 'q',
fn: function(btn, newName) {
if (btn == 'ok') {
if (newName.length > 3){
alert('ERROR');
}
}
}
});

Romick
25 Jan 2013, 1:54 AM
Seems that there is a bug in 'Ext.form.field.TextArea'



isCutCopyPasteSelectAll: function(e, key) {
if (e.CTRL) {//But should be e.ctrlKey which is boolean
return key === e.A || key === e.C || key === e.V || key === e.X;
}
return false;
}

Romick
7 Feb 2013, 3:07 PM
Can anyone confirm this issue or it just me?

evant
7 Feb 2013, 3:53 PM
Yes, looks like a bug, we'll get it fixed up.

rchernyshenko
26 Mar 2013, 4:52 AM
Could you please post fix here. I see in ext-4.2.0.663 this work. But I need this for 4.1.3

eric.cook
26 Mar 2013, 6:21 AM
It should be as simple as this (credit to Romick for the solution above):


Ext.override(Ext.form.field.TextArea, {
isCutCopyPasteSelectAll: function(e, key) {
if (e.ctrlKey) {
return key === e.A || key === e.C || key === e.V || key === e.X;
}
return false;
}
});

Key events are a touchy subject and getting a fully cross-browser and cross-platform solution is not easy. But this at least should be what the original code intended.

rchernyshenko
26 Mar 2013, 6:58 AM
Thank you