prevent NumericSetting from accepting non-numeric inputs

This commit is contained in:
Joseph Montanaro 2023-04-27 16:15:19 -07:00
parent 741169d807
commit 33a5600a30

View File

@ -10,11 +10,9 @@
export let max = null; export let max = null;
export let decimal = false; export let decimal = false;
console.log('min:', min);
const dispatch = createEventDispatcher();
let error = null; let error = null;
let localValue = value.toString(); let localValue = value.toString();
const dispatch = createEventDispatcher();
function validate(event) { function validate(event) {
localValue = localValue.replace(/[^-0-9.]/g, ''); localValue = localValue.replace(/[^-0-9.]/g, '');
// Don't update the value, but also don't error, if it's empty // Don't update the value, but also don't error, if it's empty