求一段javascript代码

来源:百度知道 编辑:UC知道 时间:2024/09/23 04:09:48
从web文本框中输入数字字母组合字段
只输出字母
例如输入12f34ghj
输出fghj

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>aaaaaaa.html</title>
<script type="text/javascript">
function aa(){

var s=document.getElementById("text1").value;
var s2="";
for(i=0;i<s.length;i++){

if(isNaN(s.charAt(i))){
s2+=s.charAt(i);

}

}
alert(s2);
}
</script>

</head>

<body>

<input type="text" id="text1" value="" ><br>
<input type="button" onclick="aa()" value="click">
</body>
</html>

alert("12f34ghj".replace(/\d+/g,''));