我正在使用此链接http://jzaefferer.github.io/jquery-validation/jquery.validate.js上给出的 validate.js 库来验证使用 Jquery 自定义对话框制作的弹出表单的文本字段。
每当我单击提交按钮时,我都会收到错误“验证未定义”..我无法理解我的代码有什么问题..
我希望插件验证弹出表单中给出的所有字段...
请帮忙..
代码..
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Animation</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"> </script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script type= text/javascript>
$(function() {
$( "#dialog1" ).dialog({
autoOpen: false,
modal: true,
resizable: false,
width:800,
height:800,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( "#opener" ).click(function() {
$( "#dialog1" ).dialog( "open" );
});
});
$(document).ready(function(){
$("#dialog").validate();
});
function isNumberKey(evt){ <!--Function to accept only numeric values-->
//var e = evt || window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<style>
textarea {
vertical-align: top;
}
</style>
</head>
<body>
<div id="dia">
<form name="dialog" method="get" action="">
<div id="dialog1" title="Upload Details">
<fieldset>
<legend><p>Please fill in the follwing Item details to compalete the uploading process.</p></legend><br><br>
Name: <input type="text" id="cIname" name="Iname"size="30" placeholder="Item Name"/><br><br>
<p><div id='ccontactform_category_errorloc' class='err'></div>
<label for="ccategory" style="margin-bottom: 90px;margin-top:50px">Category: </label>
<select id="ccategory" name="category"class="input">
<option value="0" selected="selected">
[Choose Category]
</option>
<option value="Arts and entertainment">Arts and entertainment</option>
<option value="Automotive">Automotive</option>
<option value="Business">Business</option>
<option value="Computers">Computers</option>
<option value="Games">Games</option>
<option value="Health">Health</option>
<option value="Internet">Internet</option>
<option value="News and Media">News and Media</option>
<option value="Recreation">Recreation</option>
<option value="Reference">Reference</option>
<option value="Shopping">Shopping</option>
<option value="Sports">Sports</option>
<option value="World">World</option>
</select>
<div id="choose_own_text"></div>
</p><br>
Brand: <input type="text" id="cIbrand" name="Ibrand" size="30" placeholder="Item Brand"/><br><br>
Price (Rs): <input type="text" name="price" id="cprice"size="20" placeholder="Enter Price" maxlength="15" onkeypress="return isNumberKey(event)"/> .00 ps<br><br>
<label for="cIdescrp" style="margin-bottom: 90px;margin-top:50px">Description:</label>
<textarea rows="15" cols="40" id="cIdescrp" name="Idescrp"style="resize: none;overflow:auto" onkeypress=""></textarea><br><br>
Mobile No: <input type="text" name="Num" id="cNum"size="20" placeholder="Enter Valid Number" maxlength="10" onkeypress="return isNumberKey(event)"/> <br><br>
<button id="Submit" onclick="validate()">Submit Details</button>
</fieldset>
</div>
</form>
<button id="opener">Open Dialog</button>
</div>
</body>
</html>