Search This Blog

Friday, April 28, 2023

Angular- validating the form field using adding 4 digits number

 To prevent the letter "e" from being entered as a valid character in an input field of type "number", you can use the "onkeydown" event and check if the "e" key is pressed. If the "e" key is pressed, you can prevent the default behavior of the input field, which is to allow the "e" key to be entered as part of a scientific notation number.

Here's an example of how to prevent the letter "e" from being entered in an input field of type "number" using the "onkeydown" event:

<input type="number" formControlName="frequency" class="form-control" [readOnly]="!isEditable"  inputmode="numeric" pattern="[0-9]*" onKeyPress="if(this.value.length === 4 || event.key === 'e') return false;" />

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...