How to disable enter key in form submission.

If you are looking on how to disable the enter key in form submit try this javascript code…..

onkeypress=”return event.keyCode!=13″

I tried this and tested using Firefox and IE and it works. :)

You can also try a long JS code like the following….


function disableEnterKey(e)
{
var key;

if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox

if(key == 13)
return false;
else
return true;
}

And then call this function in your HTML element (e.g input) onKeyPress=”return disableEnterKey(event)”

Reference

Comments »

The URI to TrackBack this entry is: http://cjbaldoza.blogsome.com/2006/06/16/how-to-disable-enter-key-in-form-submission/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>