Why would an <input/> box character limit be larger than accepted form submission?

时间:2016-07-11 19:29:41

标签: html forms validation input design-principles

I've seen the same thing enough times now that it's sparked my curiosity. It's even on this site!

The <input id=title ... > element on the "https://stackoverflow.com/questions/ask" sets maxlength=300 and data-max-length="150".

Namely, the input box will allow you to type 300 characters into it, but the form will not accept anything above 150.

Is there a reason one might do this?

1 个答案:

答案 0 :(得分:1)

It's most likely to prevent user from loosing end of the text while not noticing that input is limited or when pasting. After getting an error user can edit input while text is intact.