PDA

View Full Version : [CLOSED] Numberfield on Internet explorer 6



Deathtime
2 Jul 2007, 4:42 AM
Hi all,

I think keystrokes are not applying correctly to numberfields in Internet explorer 6 and 7 using Prototype+Scriptaculous libraries. Neither the cursor, delete, or NumPad keys work.

You can try the following example. Go to the Grid Example page (http://extjs.com/deploy/ext/docs/index.html), switch to the Prototype Library, edit the price value and try to change the value.

I've tried this with FF, and all works fine.

I don't know if this issue has been solved already been. If so, is there any fix we can apply?

Thanks for reading.

Edit: Found also another thread describing the problem but no answer was posted:
http://extjs.com/forum/showthread.php?t=7190&highlight=numberfield

Deathtime
11 Jul 2007, 11:27 PM
I've created a simple form using dynamic.js from your web and added a new numberfield (something like "age" or something :P) . Everything looked great but I found a little problem.

- With firefox: Everything works great.
- With IE6 and IE7: You can type numbers on a numberfield only using normal 123 keys, not with the number pad. I think this keys are block by some reason. Also, you can't use the cursor keys to move through them nor even the backtab

Only happens using Prototype/ExtJS. With yahoo or Jquery, everything works cool.

Prototype: 1.5
ExtJS: RC1

This is a re-post, as the last one didn't had much atention (0 replys).

Thanks for reading and helping.

mystix
11 Jul 2007, 11:39 PM
you don't have to repost -- just reply to your original thread with a [bump] in the message body. :)
(refer to Posting Bug Reports - A Guideline (http://extjs.com/forum/showthread.php?t=8887))

mercdev
12 Jul 2007, 12:41 PM
bump confirming issue with prototype and scriptaculous.

jack.slocum
12 Jul 2007, 12:45 PM
If it works in every lib but prototype and scriptaculous, it would seem to be an error in that lib. No one here has enough prototype knowledge to track that down. Maybe someone who is a prototype guru can help?

mercdev
12 Jul 2007, 1:39 PM
Far from a guru, however the ext-all-debug.js (~line 20659 in Ext JS Library 1.0.1) has the following:



initEvents : function(){
Ext.form.NumberField.superclass.initEvents.call(this);
var allowed = "0123456789";
if(this.allowDecimals){
allowed += this.decimalSeparator;
}
if(this.allowNegative){
allowed += "-";
}
var keyPress = function(e){
var k = e.getKey();
if(!Ext.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
return;
}
var c = e.getCharCode();
if(allowed.indexOf(String.fromCharCode(c)) === -1){
e.stopEvent();
}
};


The keycodes for the numberpad are 96-105 for #'s 0-9 respectively which do not meet the allowed.indexOf criteria. Also, why the exclusion for IE (in blue)? I'm using IE7.

mercdev
12 Jul 2007, 2:24 PM
var keyPress = function(e){
var k = e.getKey();
if(!Ext.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
return;
}

if ((k > 95 & k < 106) || k == e.BACKSPACE || k == e.DELETE)
{
return;
}

var c = e.getCharCode();
if (allowed.indexOf(String.fromCharCode(c)) === -1){
e.stopEvent();
}
};


Here's a hack/workaround to enable the delete/backspace/numberpad.

jack.slocum
12 Jul 2007, 4:37 PM
Ok, I did some digging and found this in prototype.js:


if (name == 'keypress' &&
(navigator.appVersion.match(/Konqueror|Safari|KHTML/)
|| element.attachEvent))
name = 'keydown';

Prototype rewrites keypress events to keydown events in IE and Safari. I have no clue why they would do this as a keypress !== keydown, but they do. If you edit those lines out of your prototype.js file it should work as expected.

If I were you I would report this issue to the prototype bug tracker.

mercdev
13 Jul 2007, 10:44 AM
Updating to the latest stable release of prototype.js (v1.5.1.1), then updating the lines 3025 & 3035 to the following corrected the issue, thanks for pointing that out!


if (name == 'keypress' && (Prototype.Browser.WebKit || (element.attachEvent & !Prototype.Browser.IE)))
name = 'keydown';

Deathtime
30 Jul 2007, 12:16 AM
Just came back today from vacations. T
hank you all. Tested everything and works properly now, this saves a lot of work.

This will make it solved. And sorry for the re-posting.

tryanDLS
22 Nov 2007, 9:32 AM
Why hasn't this been aswered?

mercdev pointed out something very important and relevant here and noone bothers to answer? So what seems to be the solution?
Why hasn't what been answered? It appears that this is a bug in prototype's code, or am I misunderstanding.

oneklc
10 Apr 2008, 2:39 PM
Had the same problem with prototype 1.5. Saw this forum post, upgraded prototype to the newest version (1.6.0.2, http://www.prototypejs.org/download), cleared my ie 7 browser cache and all worked like it should.