Is there a minlength validation attribute in HTML5?

前端 未结 17 1767
日久生厌
日久生厌 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:25

    You can use the pattern attribute. The required attribute is also needed, otherwise an input field with an empty value will be excluded from constraint validation.

    
    
    

    If you want to create the option to use the pattern for "empty, or minimum length", you could do the following:

    
    
    

提交回复
热议问题