How to apply min and max on textarea?

前端 未结 3 1760
生来不讨喜
生来不讨喜 2020-12-11 01:12

Is there a way in HTML5 forms to add a min and max character to a textarea? It seems I can apply it to a regular input using pattern.



        
3条回答
  •  再見小時候
    2020-12-11 01:15

    For max: see below code
    Use maxlength for maximum character.

    maxlength="nuber_of_characters"
    

    Source: http://www.w3.org/TR/html5/forms.html#the-textarea-element

    For min: source
    Use Javascript as below:
    use id attribute in

    and put following js code segment in your form tag

      

    This allow user to input no. of characters from 80 to 200.

提交回复
热议问题