Skip to Content
avatar image
Former Member

Formatting input field from 123456789 to 123-45-6789

Hi all,

I need to format an input field. When the user enters a value like 123456789, I need to default it to looks like 123-45-6789. After that I need to save the 123-45-6789 back as 123456789. Anyone have any ideas? Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jun 06, 2011 at 07:32 AM

    Hi,

    Always you want to do in that format?

    write code in on enter of that input field. Get value entered in that input field, split that in 3 parts and do cancatnation with ' -'. Again while saving just

    use previous data, what you enter in input field. you get using get_attribute.

    Cheers,

    Kris.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      try like this...

      *   navigate from <CONTEXT> to <NODE> via lead selection
          lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
      
      
      *   get single attribute
          lo_el_node->get_attribute(
            EXPORTING
              name =  `VALUE1`
            IMPORTING
              value = lv_value1 ).
      
      data : val1 type char20,
             val2 type char20,
             val3 TYPE char20.
      
      
           move  lv_value1+0(3) to val1.
           MOVE  lv_value1+3(2) to val2.
           MOVE  lv_value1+5(4) to val3.
      
      CONCATENATE val1 '-' val2 '-' val3 into lv_value1.
      
      *   get single attribute
          lo_el_node->set_attribute(
            EXPORTING
              name =  `VALUE1`
              value = lv_value1 ).

      Cheers,

      Kris.