日期:2014-05-16  浏览次数:20409 次

初学正则,不太懂DOM、表单和正则的结合,请尽量详细指点一下错误的地方,谢谢!!!~~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
<!--
function m()
{
var t=document.getElementById("a1");
var k=null;
k=t.value;
k.replace([a-z],'*');
t.value=k;
}
//-->
</script>
</head>
<body>
<input type="text" id="a1" onchange="m()" />
</body>
</html>

------解决方案--------------------
HTML code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
<!--
function m()
{
var t=document.getElementById("a1");
var k=null;
//k=t.value;
k=t.value.replace(/[a-z]/g,'*');
t.value=k;
}
//-->
</script>
</head>
<body>
<input type="text" id="a1" onchange="m()" />
</body>
</html>