Click to See Complete Forum and Search --> : Handling enter key event


kabuhassan
05-05-2003, 02:21 AM
Dear All ,

I have a jsp page that contains an input tag of type text, a select tag , other components and a client side validation written in javascript which check the validity of the user inputs .

When I select a dummy item from the list ( with index 0) then put the cursor in the input field and press enter after enters a value in the input field the script method is excuted and display " You must select an account number first " but at the same time the page getting refreshed and all the fields get it's initial values ( the page is cleaned ) .

How can I control the behaviour of the page so that it displays the error message without the refresh behaviour ?

note : the code is attached with the email .

Thanks,
Kamal.

gil davis
05-05-2003, 06:59 AM
Your attached code is apparently incomplete. The FORM tag is missing.

Most of the time, people forget to return false if an error is detected in a validation routine. There are two parts to this technique. The first is in the script:function MiniRequest1(pageName) {
...
if ((test == 0) ...
{ ...
// document.Miniform.submit(); <-- you don't need this part
return true
} else {
...
return false
}
}
The second part is in the FORM tag:
<form name="Miniform" onsubmit="return MiniRequest1('somepagename')" ... >