I had to validate a input field to accept only number and decimal, one digit after the decimal. i was able to achieve it. i also need to limit the input field such that, it should not take more than 100. I have added a condition for that but its failing. I'm validating this on keypress can anyone please let me know where im going wrong.
stackblitz editor link - <https://stackblitz.com/edit/angular-with-alternative-6zczr4>
link - <https://angular-with-alternative-6zczr4.stackblitz.io>

code:-
app.component.html

```
<div class="form-group mr-3">
    <p class="mb-0">Accepts Number
    </p>
    <input type="number" min="0" max="100" (keypress)="numberOnly($event)" class="form-control form-width" name="electricity" [(ngModel)]="electricity">
        </div>

```

app.component.ts

```
  public electricity = "";

  numberOnly(event): boolean {
    const charCode = event.which ? event.which : event.keyCode;
    const value = event.target.value;
    if (("" + event.target.value).indexOf(".") !== -1) {
      if (("" + event.target.value).split(".")[1].length > 0) {
        return false;
      }
    }
    if (event.target.value > 100) {
      return false;
    }

    if (charCode === 46) {
      return true;
    }
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
      return false;
    }
    return true;
  }

```