Forum Discussion
How to Clear or Reset Numeric entry field?
The numerical field is designed to only accept numeric values. If the value of a numeric field is set to an empty string " ", it is being interpreted as 0 as a way for the numerical field to provide a valid numeric value. If you look in the SL code you may notice that even a numeric field is the text type attribute that actually returns a string. If you are not about to do some number calculations I suggest using the text entry field instead and set its initial value to "Enter number here". Try and test this code on a single text entry field:
let numField = document.querySelector('.acc-textinput')
numField.addEventListener('input', function () {
// Get the current value of the input field
let inpVal = numField.value;
// Remove any non-numeric characters
inpVal = inpVal.replace(/[^0-9]/g, '');
// Update the input field value with the cleaned value
numField.value = inpVal;
});