JSP input focus - Websphere

This is a discussion on JSP input focus - Websphere ; Hi, I have a JSP input page with 3 text fields. I am doing the input validation in the portlet(doView method) and once any of the field validation fails, i set the error in the request and render the input ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: JSP input focus

  1. JSP input focus

    Hi,

    I have a JSP input page with 3 text fields. I am doing the input validation in the portlet(doView method) and once any of the field validation fails, i set the error in the request and render the input jsp back to the user with the error message.
    Now, my problem is after the error message i wanted the focus back to the input field, where the validation failed.

    I am checking the error message at the end of the jsp page and accordingly i am setting the focus back to the input field using the below javascript code
    document.form_name.field_name.focus();

    The problem is the focus is not SET. But if i put a alert message just before the focus javascript code, the focus is set after i respond to the alert message. I feel without the alert code, the focus is somewhere in the jsp page, but not active in the input field.

    Is there anything i need to do in order to set the focus , without adding the alert message? Or ,if there is any other best way of handling this, kindly let me know.

    Any inputs on this is hightly appreciated. Advanced thanks.






  2. Re: JSP input focus

    Hi,
    did you find the solution?
    I've the same problem... thanks.

  3. Re: JSP input focus


    Hi there,

    try this:
    document.getElementById("id1").focus();

    or better yet:
    document.getElementById("id1").select();

    gr. LucianoM

+ Reply to Thread