Home > Web Front-end > JS Tutorial > Automatically check and replace characters in text boxes

Automatically check and replace characters in text boxes

巴扎黑
Release: 2017-05-21 11:30:18
Original
1241 people have browsed it

<HTML>
<HEAD>
<META http-equiv=&#39;Content-Type&#39; content=&#39;text/html; charset=gb2312&#39;>
<TITLE>自动检查并替换文本框内的字符</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function replaceChars(entry) {
out = "a"; // 要替代的字母
add = "z"; // 替换后的字母
temp = "" + entry;
while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
document.subform.text.value = temp;
}
// End -->
</script>
</HEAD>
<BODY >
<center>
<form name="subform">
<input type=text name=text size=40 value="abcdabcd"><br>
<input type=button name=action value="Done!" onClick="replaceChars(document.subform.text.value);">
</form>
</center>

</BODY>
</HTML>
Copy after login


The above is the detailed content of Automatically check and replace characters in text boxes. For more information, please follow other related articles on the PHP Chinese website!

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