Clearing input element in mobile safari with javascript does not clear the ios autocorrect buffer

蓝咒 提交于 2019-12-14 00:59:37

问题


I have an <input type="text"> element. The user types a string and hits enter which clears the element via $('input').val(''). The problem apparently is that iOS still has the previous input string in its autocorrect buffer, so when you begin to type a new word and hit space, it sees the last word from the previous string and the first word from the new string as one 'word' and attempts to autocorrect it. Example:

message1: hello there

message2: well hi neighbor

iOS sees: therewell on messages2 and autocorrects to wellthere well

another example:

message1: hello moto

message2: boat

autocorrects to boatmotorboat where motorboat is the autocorrected version of motoboat (combination of moto from the first message and boat from the second.

I realize this may just be a bug in mobile safari and I should just disable autocorrect on the input but perhaps there is a better solution?

来源:https://stackoverflow.com/questions/18689842/clearing-input-element-in-mobile-safari-with-javascript-does-not-clear-the-ios-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!