Is there a minlength validation attribute in HTML5?

前端 未结 17 1756
日久生厌
日久生厌 2020-11-22 17:10

It seems the minlength attribute for an field doesn\'t work.

Is there any other attribute in HTML5 with the help of which I

17条回答
  •  不要未来只要你来
    2020-11-22 17:16

    In my case, in which I validate the most manually and using Firefox (43.0.4), minlength and validity.tooShort are not available unfortunately.

    Since I only need to have minimum lengths stored to proceed, an easy and handy way is to assign this value to another valid attribute of the input tag. In that case then, you can use min, max, and step properties from [type="number"] inputs.

    Rather than storing those limits in an array it's easier to find it stored in the same input instead of getting the element id to match the array index.

提交回复
热议问题