JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Text Boxes & Inputs › Numeric textbox, integer format, behaviour
Tagged: Numeric textbox
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
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/