[求助]<textarea> </textarea> 空行过滤并返回重填
不输入文字,按回车出现空行,点击确定,网页自动清除空行,并返回重填。以下代码不知哪有问题,无法实现此功能!<script>
if( form.content.value =="") {
alert("\请输入祝福语")
form.content.focus()
return false;
}
return true;
}
function isNumberString (InString,RefString)
{
if(InString.length==0) return (false);
for (Count=0; Count < InString.length; Count++) {
TempChar= InString.substring (Count, Count+1);
if (RefString.indexOf (TempChar, 0)==-1)
return (false);
}
return (true);
}
function delnull()
{
var str=document.getElementById('text').value;
str=str.replace(/([\s]*\r\n[\s]*){2,}/gm,"\r\n");
document.getElementById('text').value=str;
}
// -->
</script>
<form name=form id=form action=qq_dgsave.asp method=post onSubmit='JavaScript:checkdata()'>
<table><tr><td>
<textarea name='content' cols='80' rows='8' id='content' onbeforepaste='if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}' onBlur='this.value=ignoreSpaces(this.value);'></textarea></td></tr><tr><td><INPUT TYPE='submit' NAME='Submit' onclick=delnull() onClick='return checkdata()' VALUE=' 送 出 '> <INPUT TYPE='reset' NAME='Submit2' VALUE=' 重 写 '></td></tr></FORM></table>
if( form.content.value =="") {
alert("\请输入祝福语")
form.content.focus()
return false;
}
return true;
}
function isNumberString (InString,RefString)
{
if(InString.length==0) return (false);
for (Count=0; Count < InString.length; Count++) {
TempChar= InString.substring (Count, Count+1);
if (RefString.indexOf (TempChar, 0)==-1)
return (false);
}
return (true);
}
function delnull()
{
var str=document.getElementById('text').value;
str=str.replace(/([\s]*\r\n[\s]*){2,}/gm,"\r\n");
document.getElementById('text').value=str;
}
// -->
</script>
<form name=form id=form action=qq_dgsave.asp method=post onSubmit='JavaScript:checkdata()'>
<table><tr><td>
<textarea name='content' cols='80' rows='8' id='content' onbeforepaste='if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}' onBlur='this.value=ignoreSpaces(this.value);'></textarea></td></tr><tr><td><INPUT TYPE='submit' NAME='Submit' onclick=delnull() onClick='return checkdata()' VALUE=' 送 出 '> <INPUT TYPE='reset' NAME='Submit2' VALUE=' 重 写 '></td></tr></FORM></table>
[[it] 本帖最后由 thbwn 于 2008-2-11 16:06 编辑 [/it]]