Added code to only allow one period when using inputNumber.
This commit is contained in:
@@ -40,7 +40,14 @@ IgniteTemplate.prototype.inputNumber = function(maxLength = -1) {
|
|||||||
if ((e.key < '0' || e.key > '9') && e.key != 'Backspace' && e.key != 'Escape' && e.key != 'Tab' && e.key != 'Control' && e.ctrlKey == false && e.key != '.') {
|
if ((e.key < '0' || e.key > '9') && e.key != 'Backspace' && e.key != 'Escape' && e.key != 'Tab' && e.key != 'Control' && e.ctrlKey == false && e.key != '.') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
//Only allow one period
|
||||||
|
else if (e.key == '.' && e.target.value.includes('.')) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//Otherwise check for special keys
|
||||||
|
else {
|
||||||
//If we reached the max and the key isn't a special one then block this.
|
//If we reached the max and the key isn't a special one then block this.
|
||||||
if (maxLength != -1 && e.target.value.length >= maxLength && e.key != 'Backspace' && e.key != 'Escape' && e.key != 'Tab' && e.key != 'Control' && e.ctrlKey == false) {
|
if (maxLength != -1 && e.target.value.length >= maxLength && e.key != 'Backspace' && e.key != 'Escape' && e.key != 'Tab' && e.key != 'Control' && e.ctrlKey == false) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user