I’m using jquery’s popular Validate plugin to validate all my fields. This works great when the input fields are not running at server and thus not renaming all the IDs and Names for the input.
I’m wondering if there is a different way to select the input in the jquery so I can still use the plugin. The jquery is below:
<script type="text/javascript">
jQuery.validator.messages.required = "";
$(document).ready(function () {
$('#form1').validate({
rules: {
firstName: {
required: true,
},
}
});
});
Currently, if I use an <asp:TextBox.../> the ID comes out to “ContentPlaceHolderBody_firstName” and the name comes out to “ctl00$ContentPlaceHolderBody$firstName”.
I even tried replacing the name in the jquery to reflect both the ID and the name to no avail.
What is the best way around this? Can I add a class and select that way? And if so, what would the jquery selector look like?
Any help is appreciated! Thanks!
Go to asp.net 4.0
http://weblogs.asp.net/scottgu/archive/2010/03/30/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series.aspx