Home > Blockchain >  indexOf in HTML with min length
indexOf in HTML with min length

Time:03-02

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">

CodePudding user response:

You can use the “pattern” attribute, like so:

<form>
  <input type="text" minlength="10" maxlength="12" pattern="[0-9]. ">
  <input type="submit">
</form>

CodePudding user response:

If you're open to using Library Joi npm does this really well.

  •  Tags:  
  • html
  • Related