When user enters an alphabets other then numbers then input box should not allow it. It is working in given example. But when user enters the numbers and if it is more then the specified value (i.e. maxValue) that time want to apply the stop Propagation. But it is not working. So here user should not be able to enter other then numbers and also when the value becomes more then the specified maxValue then it should not allow the user to enter.
- How to solve this problem ?
- Why this is perfectly working for alphabets check and not working for maxValue check ?
Please find the jsfiddle link -
https://jsfiddle.net/d6aqn3g4/1/
code :
onInputChange(event) {
const initalValue = event.target.value;
event.target.value = initalValue.replace(/[^0-9]*/g, '');
// here user can not enter any alphanets
// but here we wan user to not allow enter when value is more then maxValue
if ( initalValue !== event.target.value || parseInt(event.target.value) > this.maxValue) {
event.stopPropagation();
return false;
}
}
Thanks in Advance.