Skip to Content
avatar image
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.

Regards

Sandesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Aug 25, 2014 at 06:15 AM

    Hi,

    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,

    Regards,

    Kiran

    Add comment
    10|10000 characters needed characters exceeded