cancel
Showing results for 
Search instead for 
Did you mean: 

JS to restrict inputfield to numeric values in tableview

former_member184111
Active Contributor
0 Kudos

Hi All,

I have a table view with one field editable , the user should be able to enter only numbers and only upto 4 numbers.I searched the forum and found the thread:

but it gives the OBJECT EXPECTED error , moreover what modifications are required to use for an inputfield in tableview and restrivt length to four....

Thanks,

Anubhav Jain.

Accepted Solutions (0)

Answers (1)

Answers (1)

athavanraja
Active Contributor
0 Kudos

are you using iterator to render input field in TV? if yes

to restrict the length

p_replacement_bee = cl_htmlb_inputfield=>factory(

id = p_cell_id

disabled = 'true'

maxlwngth = '4' ).

and to trigger the js function for onchange of value in the field.

write the following code in the layout just after the htmlb:tableview


< sc ript for="<tableviewcell id>" eve nt=onch ange type="te xt/javas cript">
      checkNu meric();
      < /s crip t>

former_member184111
Active Contributor
0 Kudos

Hi Raja,

My iterator code is:

WHEN 'QTY'.
      IF p_edit_mode IS NOT INITIAL.
        DATA: qty TYPE string.
        matnr = m_row_ref->qty.
        DATA: if_fifth TYPE REF TO cl_htmlb_inputfield.
        if_fifth = cl_htmlb_inputfield=>factory( id = p_cell_id id_postfix = '_fifth'
                                                 alignment = 'center' maxlength = '6'
                                                      size = '6'
                                                      type = 'BCD'
                                                      decimals = '2'
                                                      dovalidate = 'TRUE'
                                                      cellvalue = 'TRUE').

But it does not restricts the field length to 6 .

What am i doing wrong?

Thanks,

Anubhav.