我一直在尝试验证此表格:
<table>
<form action="test.html" method="post" id="contactform" name="contactform">
<tr>
<td>
<label for="fname">First Name :</label>
</td>
<td>
<input name="fname" id="fname" type="text" />
</td>
</tr>
<tr>
<td>
<label for="lname">Last Name :</label>
</td>
<td>
<input name="lname" id="lname" type="text" />
</td>
</tr>
<tr>
<td>
<label for="gender">Gender :</label>
</td>
<td>
<input name="gender" id="genderm" type="radio" /> Male <input name="gender" id="genderf" type="radio" /> Female
</td>
</tr>
<tr>
<td>
<label for="email">Email :</label>
</td>
<td>
<input name="email" id="email" type="text" />
</td>
</tr>
<tr>
<td>
<label for="address">Address :</label>
</td>
<td>
<input name="addr" id="addr" type="text" />
</td>
</tr>
<tr>
<td>
<label for="mob">Mobile Phone :</label>
</td>
<td>
<input name="mob" id="mob" type="text" />
</td>
</tr>
<tr>
<td>
<label for="dob">Date Of Birth (mm/dd/YYYY):</label>
</td>
<td>
<input name="dob" id="dob" type="text" />
</td>
</tr>
<tr>
<td>
<label for="agreeT">By Checking This you agree to our Terms :</label>
</td>
<td>
<input name="agreeT" id="agreeT" type="checkbox" />
</td>
</tr>
<tr>
<td>
<input type="submit" value="Sumbit" />
</td>
</tr>
但我无法使用 Jquery Validation Plugin 验证它我在我的文件中添加这些脚本代码:
<script src="jquery.js"></script>
<script src="jquery.validate.js"></script>
<script language="javascript">
$(document).ready(function(e) {
var validator = $("#contactform").validate({
rules : {
fname: "required",
lname: "required",
email: {
email: true,
required: true
},
gender:" required",
addr: "required",
dob: {
required: true,
date: true
},
agreeT: "required"
}
}
);
});
</script>
谁能告诉我为什么我要在不验证表单的情况下访问 test.html....??有语法错误吗??