On Oct 13, 4:52 pm, kcnu <[EMAIL PROTECTED]> wrote:
> Hello All,
>
> I need some help to add 'onkeypress' event attribute to HTML <INPUT>
> elements.
There's a bit easier solution:
$$('input[type=text]').invoke('observe', 'keypress', function(e) {
if (!test()) e.stop();
});
>
> Below code works fine in Firefox, but not at all in IE 7.
>
> var inputs = document.getElementsByTagName("input");
> for (i = 0; i < inputs.length; i++ )
> {
> if(inputs[i].type == 'text'') {
> alert('name is-->>>'+inputs[i].name);
> inputs[i].setAttribute("onkeypress",
> "javascript:return test()");
> }
> }
>
> Tried writeAttribute() in prototype 1.6.0.2 too but no use in IE 7.
But if you don't feel like using `observe`, just assign a function
reference, rather than setting attribute:
inputs[i].onkeypress = function(e) {
e = e || window.event;
...
}
>
> Thanks,
> Kcnu
--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---