我在母版頁一個jQuery表單驗證,它工作正常,我得到了從這篇文章的工作:http://www.dotnetcurry.com/ShowArticle.aspx?ID=310jQuery的表單驗證:驗證腳本指定外部
我的問題是:如果我放在.js文件外部和引用添加到我的網頁,然後它不工作...它說對象預期
這裏是如何我做:
在我的內容頁(我使用母版頁,asp.net)
加入我的騙局10噸頁:
<script src="myform_validation.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
ValidateMe(this);
});
</script>
下面是在外部.js文件:
function ValidateMe() {
$("#aspnetForm").validate({
rules:
{
<%=TextBox1.UniqueID %>:
{
maxlength:1,
//minlength: 12,
required: true
},
<%=TextBox2.UniqueID %>:
{
minlength: 12,
required: true
},
<%=TextBox3.UniqueID %>:
{
minlength: 12,
required: true
}//,
//
},
messages:
{
<%=TextBox1.UniqueID %>:
{
required: "Enter your firstname",
minlength: jQuery.format("Enter at least {0} characters")
},
<%=TextBox2.UniqueID %>:
{
required: "Please enter a valid email address",
minlength: "Please enter a valid email address"
} ,
<%=TextBox3.UniqueID %>:
{
required: "Enter your firstname",
minlength: jQuery.format("Enter at least {0} characters")
}
} ,
success: function(label) {
// set as text for IE
label.html(" ").addClass("checked");
}
});
} ;
您是否在外部js中包含了jquery引用? – melaos 2010-04-23 14:56:35