JS 替换文本域内的回车

<html> 
<head> 
<title>无标题文档</title> 
<script type="text/javascript">
function aa()
{
    s
=form1.t1.value;
    s=s.replace(/\n|\r/g,"");
//  加上g是全局替换,不加只替换第一个  是回车、是换行符
    form1.t1.value=s;
}
</script>
</head> 
<body> 
<form name="form1">
<textarea  name="t1" style="height: 74px"></textarea>
<input type="button" value="aa" onclick="aa()">
</form>
</body> 
</html> 
posted @ 2011-02-26 11:57  郑文亮  阅读(592)  评论(1编辑  收藏  举报