Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #108961

    Using numeric textbox with an integer format if I write a float number (say 1.7) the number is rounded to 2.

    Is it possible to avoid the introduction of ., etc.. if format is integer in order to avoid rounding ?

    Tks

    #108970

    Hi,

    You can prevent the addition of chars that are not Numbers this way:
    const input = document.querySelector(“#integer-input”);

    input.addEventListener(‘keydown’, function (event) {
    if(isNaN(event.key) && event.key != ‘Backspace’) {
    event.preventDefault()
    }
    })

    This way, the user will not be able to add , or .

    Best Regards,
    Svetoslav Borislavov

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

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