Hi ,
I am building a web application using jsp and javascript
there is a requirement whenever use press “Enter” Button the form will be submitted so i use this method below
[CODE]document.onkeypress = submitViaEnter;
function submitViaEnter(evt) {
evt = (evt) ? evt : event;
var target = (evt.target) ? evt.target : evt.srcElement;
var form = target.form;
var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
if (charCode == 13 || charCode == 3) {
//submit the form
}
}
but there is a problem for textarea that should be excluded in this case.
how do i do that?
one way i can think of is whenever javascript there is a “Enter” event can we check if the user press “Enter” Button from inside the textarea so we dont submit the form..
or is there any other way?
Thanks.