I am using jQuery validation plugin( latest version downloaded, added in my project) in asp.net project.
The problem is, my validation rules are in a separate js file. So when I type in <%=textbox.UniqueID%> I get an error - Expected identifier, string or number. I added quotes to make it a string - "<%=textbox.UniqueID%>" and now its just viewed as a string - it does not get the unique id of the text box.
But when I put these validations in .aspx page it's working fine but this is not I want, I want to put validations in separate js file
Here is what I have tried
filename: customscript.js
$("#form1").validate({
rules: {
<%= txtOtprId.UniqueID %>: //here I am getting error Expected identifier, string or number
{
required: true,
alphanumeric: true,
minlength: 12,
maxlength: 12
},
<%= txtName.UniqueID %>: //here i am getting error
{
required: true,
lettersonly: true
}
}
});
<%= %>items are meant to be replaced by the server when it renders the page. However, the server does not render .js files, nor would it know whattxtOtprIdis if that control is specified in another file.