<!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>
问题如下:
1、<input type="submit" name="cmxform_Submit" id="cmxform_Submit" value="提交" /> 我想把type类型修改button,验证就不能执行了,之前网上也受过很多东西也试过都没有得到想要的答案。
希望各位大侠能给小弟一个非常满意的答案,谢谢啦。。。这个困扰我很长时间了。。。。
------解决方案--------------------
把 <input type="submit" name="cmxform_Submit" id="cmxform_Submit" value="提交" />