在php中很容易就实现了,只需要在接收form内容的页面里面使用字符串替换!下面说的是直接用javascript来实现
<a>的onclick 可以 return false来阻止,但是<input type="submit">似乎不行
<html>
<head>
<title>雨夜心情</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="css/style.css" type="text/css">
<script language=javascript>
function HTMLEncodes(fString){
if(fString!=null){
fString =fString.replace(/>/g, ">");
fString =fString.replace(/</g, "<");
return fString;
}
}
function mysubmit()
{
if(form1.content.value==""){alert(‘请输入留言内容!’); form1.content.focus(); return false;}
form1.username.value = HTMLEncodes(form1.username.value);
form1.content.value = HTMLEncodes(form1.content.value);
alert(form1.username.value);
form1.submit();
}
function myreset()
{
form1.reset();
form1.title.value=1;
document.titleface.src=’img/face/1.gif’;
}
</script>
</head>
<body >
<form name="form1" method="post" action="check.php" >
<table width="50%" border="0" align="center" bgcolor="#FFFFFF">
<tr align="center">
<td colspan="4" height="144">
<textarea name="content" rows="10" cols="56"></textarea>
</td>
</tr>
<tr align="center">
<td colspan="4" height="20"> <a href="#">
<input type="button" value="提交" onClick="mysubmit()">
</a>
<a href="#"><img src="img/reset.gif" width="79" height="22" OnClick="javascript:if(!myreset()) return false;" border="0"></a></td>
</tr>
</table>
</form>
</body>
</html>
check.php
<?php
echo $_REQUEST[‘content’];
?>