Is there a minlength validation attribute in HTML5?

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

    If desired to make this behavior, always show a small prefix on the input field or the user can't erase a prefix:

       // prefix="prefix_text"
       // If the user changes the prefix, restore the input with the prefix:
       if(document.getElementById('myInput').value.substring(0,prefix.length).localeCompare(prefix))
           document.getElementById('myInput').value = prefix;
    

提交回复
热议问题