Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #110705

    I tried to use a numeric textbox with a max-length of four but  I can write how many characters I want.

    Is it possible to limit the number of introduced characters in a number ?

    Tks

    #110706
    ivanpeevski
    Participant

    Hi,

     

    The numeric textbox has a “max” property. If you set it to 9999 and the user enters a larger number, the value will automatically reduce to 9999 when the user leaves the field.

     

    If you want to fully disable entering more than 4 characters you can set: document.querySelector(‘smart-numeric-text-box input’).setAttribute(‘maxlength’, 4)

     

    Best Regards,
    Ivan Peevski
    Smart UI Team
    https://www.htmlelements.com/

    #110715

    Tks for your help but I wasn’t able to apply it.

    I tried

    document.querySelector(‘#e18042434’).input.setAttribute(‘maxlength’, 4) but also

    document.querySelector(‘#e18042434 input’).setAttribute(‘maxlength’, 4)

    I can use only the id of the smart-numeric-text-box because I’ve many in the same page  with different lengths.

    Could You suggest the correct expression ?

    Tks

    #110717
    Markov
    Keymaster

    Hi,

    You can try the significant digits property: https://www.htmlelements.com/docs/numerictextbox-api/#toc-significantdigits_number

    Best Regards,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

    #110719

    It seems to be valid only for float and not for integers.

    Tks

    #110723
    ivanpeevski
    Participant

    Hi,

     

    The numeric textbox must be already initialized for using the maxLength attribute. Here is an example – codepen

     

    Best Regards,
    Ivan Peevski

    Smart UI Team
    https://www.htmlelements.com/

    #110725

    Tks.

    Just for my better understanding why did You use a timeout event to trigger the operation ?

     

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.