请问谁有在客户端验证非法字符(特别是单引号和双引号)的完整代码?先谢谢了。

7710703 2001-09-05 08:46:50
加精
...全文
117 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
liaogs 2001-09-05
  • 打赏
  • 举报
回复
你看看sohu的得注册就知道了!
viking 2001-09-05
  • 打赏
  • 举报
回复


<script language="javascript">
<!--
strcontent=theForm.txtcontent.value;
if(strcontent.length>0)
{
i=strcontent.indexOf("'");
if(i==-1)
{
window.alert("对不起!您输入的内容是错误地!")
//处理语句
//-->
</script>

如果检验双引号可能会麻烦一点,最好到服务器端验证,你先用这段代码试试吧!


www525 2001-09-05
  • 打赏
  • 举报
回复
如下:
a=trim(request.form("a"))
a=replace(a,"'","''")
a=replace(a,"<","<")
a=replace(a,">",">")
longyear 2001-09-05
  • 打赏
  • 举报
回复
把字符一个个拿出来比较就行了!
wybm 2001-09-05
  • 打赏
  • 举报
回复
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
<!--
String.prototype.Trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}
function check(){
var StrValue=document.form1.str.value.Trim()
if(StrValue==""){
alert("Plese type in the string!")
document.form1.str.focus();
return false;
}
if (StrValue.indexOf("'")!=-1){
alert("The String is invalid");
document.form1.str.focus();
return false;
}
if (StrValue.indexOf('"')!=-1){
alert("The String is invalid");
document.form1.str.focus();
return false;
}
alert("All the best")
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<form name="form1" method="post" action="">
<p>
<input type="text" name="str" size="40">
</p>
<p>
<input type="button" name="Button" value="Button" onclick="javascript:check()" style="cursor:hand">
</p>
</form>
</div>
</body>
</html>
7710703 2001-09-05
  • 打赏
  • 举报
回复
www525兄说的是什么意思?双引号呢?

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧