Example of automatically jumping to the last character after the input box in HTML is modified

黄舟
Release: 2017-10-23 09:58:34
Original
3520 people have browsed it

Instance of the input box in html automatically jumping to the last character after modification

<input class="m-form-control" onpaste="return false" placeholder="直播间名称" 
name="name" onkeyup="this.value=this.value.replace(/[^\u4e00-\u9fa5|\u0000-\u00ff|\u3002|\uFF1F|
\uFF01|\uff0c|\u3001|\uff1b|\uff1a|\u3008-\u300f|\u2018|\u2019|\u201c|\u201d|\uff08|\uff09|\u2014|\u2026|\u2013|\uff0e]/g,&#39;&#39;)" 
onafterpaste="this.value=this.value.replace(/[^\u4e00-\u9fa5|\u0000-\u00ff|\u3002|\uFF1F|\uFF01|\uff0c|\u3001|
\uff1b|\uff1a|\u3008-\u300f|\u2018|\u2019|\u201c|
\u201d|\uff08|\uff09|\u2014|\u2026|\u2013|\uff0e]/g,&#39;&#39;)">
Copy after login

There are three events, one onpaste is used to prohibit pasting, and the remaining two are used to remove special characters. The reason is replace, replace will be like re-typing, so the cursor will be resolved at the end

, and the replace event will be triggered when the cursor is lost

The above is the detailed content of Example of automatically jumping to the last character after the input box in HTML is modified. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template