'Using pattern RegEx validation in ionic directly in HTML

I am trying to validate forms in ionic using pattern validator. Now I have seen examples of ng-Pattern and pattern being directly used in HTML in web but I haven't seen such an implementation in ionic.

<input id="{{list.fieldName}}" type="text"
        class="form-control"
        [(ngModel)]="newUser[list.fieldName]"
        [maxlength]="maxlength[list.sequenceNo]"

        [pattern]="patternStatus[field.sequenceNo]"/>

While debugging, I can even see the pattern like this pattern="/(^[0-9]{0,10}$)/" (RegEx to validate numbers) in the HTML but its not validating.

Is there a way to do it directly in HTML or do I have to use Validators and FormControls? By the way maxlength validation is working here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source