mardi 10 juillet 2018

Execute a (click) or (keyup) event method only if the value matches with pattern in angular 4+

Below is the HTML code, the keyup will be triggered only if the input field value matched with the pattern.

<input (keyup)="checkPatternMatch(ProjectName)" type="text" #ProjectName="ngModel" name="pro-name" class="form-control" pattern=".*\S+.*">


pattern=".*\S+.*"

this pattern should atleast contains a single character (it does not consider space as a character).

Aucun commentaire:

Enregistrer un commentaire