JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Text Boxes & Inputs › Numeric textbox, integer format, behaviour › Reply To: Numeric textbox, integer format, behaviour
October 13, 2023 at 7:54 am
#108970
svetoslav_borislavov
Participant
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/