检测文本框内容 禁止输入"<%"或"%>"字符

来源:百度知道 编辑:UC知道 时间:2024/06/06 06:08:37
我要做个ASP互动程序
但是文本框禁止填写如"<%"
用脚本检测出来!
怎么编写
<form action="" method="post" name=form1>
<tr bgcolor="#FFFFFF">
<td width="27%">
<textarea name="ad" cols="66" rows="8" ></textarea></td>
</tr>
<tr>
<td width="27%" valign="bottom">
<input type="submit" value="修改" name="edit">
<input type="reset" value="取消" name="reset">
</td>
</tr></form>

<script>
function chk(form){
var str = form.ad.value;
if(str.length > 0 && str.indexOf('<%') != -1)
{
alert('错误');
return false;
}
}
</script>
<form action="" method="post" name=form1 onsubmit="return chk(this);">
<tr bgcolor="#FFFFFF">
<td width="27%">
<textarea name="ad" cols="66" rows="8" ></textarea></td>
</tr>
<tr>
<td width="27%" valign="bottom">
<input type="submit" value="修改" name="edit">
<input type="reset" value="取消" name="reset">
</td>
</tr></form>

你把你的文件代码给我 我马上去吃饭 回来给你解决 我qq93934300

<SCRIPT LANGUAGE="JavaScript">
<!--
var re=/(?:<