<input class="qty-input-wrapper" type="number" (keypress)="isNumberKey($event)">
isNumberKey(event: any) {
const pattern = /[0-9\+\-\ ]/;
let inputChar = String.fromCharCode(event.charCode);
if (!pattern.test(inputChar)) {
// invalid character, prevent input
event.preventDefault();
}
}
css:
.qty-input-wrapper {
border-radius: 20px;
text-align: center;
border: 1px solid #E6E6E6;
padding: 5px;
width: 50%;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}