Issue with ‘onEnter’ on a formless text box

Recently, I had issues with a set of text boxes which were not within a form. The onEnter  (when pressed enter) on any of the text boxes would refresh the page as it was considered a submit by default.

This was causing problems in the page where I had an AJAX application.

So, we need to cancel the event trigger by ‘enter’.

This is done by  the following line- the ‘enter’ is code 13 on the keyboard – (in the element like text box)

onKeyPress=”return event.keyCode!=13″

Post a Comment