'indexOf in HTML with min length
I have some element containes alphabates & number as input example :- 12EDFG3456 , 73WERTY1234 etc. All these elements starts with number and then contains some alphabates + Number. In HTML , while creating frontend, we have used minLength method which will check first , the length of these elements which is fine. I am trying to keep one more check where we are making sure elements start with Numbers.
Can we use index (to check index place 0 ) and check if it is number , if yes then check minLengh and so on.?<mat-label> element </mat-label>
<input matInput minlength ="10" maxlength ="12" name= "traNum formControlName ="traNum">
Solution 1:[1]
You can use the “pattern” attribute, like so:
<form>
<input type="text" minlength="10" maxlength="12" pattern="[0-9].+">
<input type="submit">
</form>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RatajS |
