Skip to Content
author's profile photo Former Member
Former Member

How to set cursor/focus on input field

Hi Experts ,

I have ten input fields on view,all are mandatory fields my requirement is after clicking on submit button if any of the input field is not entered

then cursor/Focus should be on that input field ,can anybody tell me the solution advance thanks.



Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Posted on Aug 25, 2014 at 06:15 AM


    Are you displaying any error messages if the field is initial? If so, you cannot set focus on field as the focus will be shifted to message area. you can use report_attribute_error_message( ) method of message manger to highlight the input field(in red color, but no focus set).

    If you want to set the focus without any error messages, use the below code

    DATA: lr_elem TYPE REF TO if_wd_view_element.

    lr_view type ref to if_wd_view.

    lr_view ?= wd_this->wd_get_api( ).

    lr_elem = view->get_element( 'INP1' )." INP1 is the UI element ID of input field1

    lr_view->request_focus_on_view_elem( lr_elem ).

    hope this helps,



    Add comment
    10|10000 characters needed characters exceeded