fix regex and make empty string go back to old value on change
This commit is contained in:
parent
c82e714cb1
commit
8115f0b850
1 changed files with 3 additions and 3 deletions
|
@ -254,13 +254,13 @@
|
||||||
change (event) {
|
change (event) {
|
||||||
let val = event.target.value.trim();
|
let val = event.target.value.trim();
|
||||||
|
|
||||||
if (event.type == 'input' && val.match(/^\.$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
|
if (event.type == 'input' && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
|
||||||
if (event.type == 'change' && Number(val) === this.currentValue) return; // already fired change for input event
|
if (event.type == 'change' && Number(val) === this.currentValue) return; // already fired change for input event
|
||||||
|
|
||||||
const {min, max} = this;
|
const {min, max} = this;
|
||||||
|
const isEmptyString = val.length === 0;
|
||||||
val = Number(val);
|
val = Number(val);
|
||||||
if (!isNaN(val)) {
|
if (!isNaN(val) && !isEmptyString) {
|
||||||
this.currentValue = val;
|
this.currentValue = val;
|
||||||
|
|
||||||
if (val > max) {
|
if (val > max) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue