日期:2014-05-16 浏览次数:20649 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body{ font-size:12px;}
form.cmxform label.error, label.error {
color: red;
font-style: italic;
cursor:pointer;
margin-left:12px;
font-size:12px;
}
input:focus { border:1px solid #F00; }
input.error { border:1px solid #F00; }
</style>
<script src="jquery-1.4.2.js"></script>
<script src="jquery.validate.js"></script>
<script>
$(function(){
$("#cmxform").validate({
rules:{
title: "required",
content: "required",
},
messages:{
title:"空是不行的",
content: "content",
}
});
$("#text").load("ajax.php");
$("#cmxform_Submit").click(
function(){
$.ajax({
url: "ajax.php",
data:"title="+$("#title").val()+"&content="+$("#content").val()+"&action=add",
type:"POST",
success:function(data){$("#text").html(data);},
});
$("#title").val("");
$("#content").val("");
}
);
});
</script>
<title></title>
</head>
<body>
<div id="text"></div>
<div style="height:6px;"></div>
<hr />
<div id="nav">
<form method="post" id="cmxform" name="cmxform">
<table border="0" cellpadding="0" cellspacing="6" style="font-size:12px;" bgcolor="#CCCCCC">
<tr>
<td>标题:</td>
<td><input name="title" type="text" id="title" size="30" /></td>
</tr>
<tr>
<td>评论:</td>
<td><textarea name="content" cols="24" rows="5" id="content"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="cmxform_Submit" id="cmxform_Submit" value="提交" /> <input type="reset" value="重置" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>