自动检查并替换文本框内的字符

时间:2006-06-30    点击:117   

<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>

Javascript的IE和Firefox兼容性汇编
提高代码性能技巧谈—以创建千行表格为例
对textarea框的代码调试,而且功能上使用非常方便,酷
列表内容的选择
会自动逐行上升的文本框
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved