自動檢查并替換文本框內(nèi)的字符
<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html; charset=gb2312'>
<TITLE>自動檢查并替換文本框內(nèi)的字符</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>
相關(guān)文章
JavaScript?設(shè)計模式之洋蔥模型原理及實踐應(yīng)用
這篇文章主要介紹了JavaScript?設(shè)計模式之洋蔥模型原理及實踐應(yīng)用,主要針對項目中遇到的問題,引申到koa-compose原理解析。通過學(xué)習(xí)洋蔥模式來解決我們實際項目中的問題2022-09-09
Js原型鏈constructor prototype __proto__屬性實例詳解
這篇文章主要介紹了Js原型鏈constructor prototype __proto__屬性實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-10-10

