B
browntown
so I have this application I'm nearly finished with. The only thing the
client has requested is the ability to submit the form by pressing
"enter". I didn't think this would be a huge pain in the ass and the
app will be used internally so I'm not too worried about users who
aren't using javascript. I'm using the following javascript to detect
whether or not they've hit enter:
if(document.layers)
{
document.addEventLister('onkeypress', kpress, true);
}
document.onkeypress=kpress;
function kpress(e)
{
if(window.event)
{
//ie code
key = window.event.keyCode;
}
else
{
key = e.which;
}
//user has pressed enter/return...let's submit the form
if(key == 13)
{
document.forms[0].submit();
}
}
this works fine. It submit all inputs fine...with the exception of my
image buttons. I'm using "image_x" to validate whether or not the form
was submitted by the user. Since "image" type inputs are not being
submitted I can't validate the form. If I change the "image" to
"submit" I get a "Object doesn't support this property or method" error
in IE and a "document.forms[0].submit is not a function" in firefox.
anyone have any ideas?
client has requested is the ability to submit the form by pressing
"enter". I didn't think this would be a huge pain in the ass and the
app will be used internally so I'm not too worried about users who
aren't using javascript. I'm using the following javascript to detect
whether or not they've hit enter:
if(document.layers)
{
document.addEventLister('onkeypress', kpress, true);
}
document.onkeypress=kpress;
function kpress(e)
{
if(window.event)
{
//ie code
key = window.event.keyCode;
}
else
{
key = e.which;
}
//user has pressed enter/return...let's submit the form
if(key == 13)
{
document.forms[0].submit();
}
}
this works fine. It submit all inputs fine...with the exception of my
image buttons. I'm using "image_x" to validate whether or not the form
was submitted by the user. Since "image" type inputs are not being
submitted I can't validate the form. If I change the "image" to
"submit" I get a "Object doesn't support this property or method" error
in IE and a "document.forms[0].submit is not a function" in firefox.
anyone have any ideas?