Edge浏览器中的input输入框问题

代码如下:

<input type="text" maxlength="10"/>

Edge浏览器中输满十个字后,再把光标放在内容中继续输入,新输入的内容会替换旧内容,其他浏览器没发现这个问题。这是什么情况,貌似仅限于中文,怎么避免?
图片描述
这是输满是个字的时候,此时我把光标移入内容中,开始输新的内容

图片描述

发现旧的内容被替换。

阅读 7.9k
1 个回答

Bootstrap 网站上测试 maxlength,没发现这个问题,超出10个字符直接禁止其他键盘输入了。
把你的代码嵌在页面里测试也没能重现你的问题。
你看看把光标往前移动会不会发现被覆盖的字符?

The maxLength property limits the number of characters the user can enter. The property does not limit programmatic assignments to the value property. The property's value can be larger than the size of the text box, in which case the text box scrolls as the user types.
——Windows Dev Center:maxlength attribute | maxLength property

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题