Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.8.2
-
Fix Version/s: 1.8.2-EE-GA_P01, 1.8.3
-
Component/s: ICE-Components
-
Labels:None
-
Environment:Icefaces rev.20220
-
Workaround Exists:Yes
Description
If user define maxlength then script Ice.txtAreaMaxLen is fired on some events, like below:
<TEXTAREA onmousedown="this.focus();" onkeydown="Ice.txtAreaMaxLen(this,140);" onblur="iceSubmitPartial(form, this, event);" onchange="Ice.txtAreaMaxLen(this,140);" (...)></TEXTAREA>
But the same script cannot be fired onkeydown and onchange. Event onkeydown should return false if new char exceeds range
This patch should helps
<TEXTAREA onmousedown="this.focus();" onkeydown="return Ice.txtAreaMaxLen(this,140);" onblur="iceSubmitPartial(form, this, event);" onchange="Ice.txtAreaMaxLen(this,140);" (...)></TEXTAREA>
Ice.txtAreaMaxLen = function(field, maxlength) {
if (maxlength >= 0) {
if(field.value.length == maxlength)
return false;
if(field.value.length > maxlength)
field.value = field.value.substring(0, maxlength);
}
return true;
}
<TEXTAREA onmousedown="this.focus();" onkeydown="Ice.txtAreaMaxLen(this,140);" onblur="iceSubmitPartial(form, this, event);" onchange="Ice.txtAreaMaxLen(this,140);" (...)></TEXTAREA>
But the same script cannot be fired onkeydown and onchange. Event onkeydown should return false if new char exceeds range
This patch should helps
<TEXTAREA onmousedown="this.focus();" onkeydown="return Ice.txtAreaMaxLen(this,140);" onblur="iceSubmitPartial(form, this, event);" onchange="Ice.txtAreaMaxLen(this,140);" (...)></TEXTAREA>
Ice.txtAreaMaxLen = function(field, maxlength) {
if (maxlength >= 0) {
if(field.value.length == maxlength)
return false;
if(field.value.length > maxlength)
field.value = field.value.substring(0, maxlength);
}
return true;
}
Issue Links
- depends on
-
ICE-3458 Add maxlength attribute to inputTextarea
-
- Closed
-
Fixed script for modern browsers.
Ice.txtAreaMaxLen = function(field, event, maxlength) {
{ key = window.event.keyCode; }var key;
if (window.event)
else if (event)
{ key = event.which; }else
{ return true; }// ignore control keys
if ((key==null) || (key<13) || ((key>=35) && (key<=40)) || (key==91) || (key==92) || (key==93) ) { return true; }
if (maxlength >= 0){
{ return true; }if (field.value.length == maxlength) {
// ignore delete and insert
if ( (key==46) || (key==45) )
else
{ return false; }}
{ field.value = field.value.substring(0, maxlength); }if (field.value.length > maxlength)
}
return true;
}