jquery form validation: validation script specified externally
Posted
by Abu Hamzah
on Stack Overflow
See other posts from Stack Overflow
or by Abu Hamzah
Published on 2010-04-23T14:50:58Z
Indexed on
2010/04/23
14:53 UTC
Read the original article
Hit count: 472
i have a jquery form validation in the master page and it works fine and i got that working from this article: http://www.dotnetcurry.com/ShowArticle.aspx?ID=310
my question is: if i place the .js to external and add a reference to my page then its not working... it says object expected
here is how i have done:
in my content page (i am using master page, asp.net )
add in my content page:
<script src="myform_validation.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
ValidateMe(this);
});
</script>
below is in the external .js file:
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");
}
});
} ;
© Stack Overflow or respective owner