Posted in Javascript onJune 30, 2006
<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html; charset=gb2312'>
<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>
自动检查并替换文本框内的字符
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@