0
Reply

Getting control name like ClientID for use in JQuery

Ask a question
J D

J D

14y
2.4k
1

I am working on setting up validation with JQuery in my .Net code. I got some things working, but cant figure this 1 out.
The following code shows how to set a simple rule to an input field called agree i JQuery.
$("#MainForm").validate({
            rules: { 
              agree: "required"   
  }
        });
My problem is that its the fields name which is needed and not the ID. The field IDs and names change with the control tree in .Net
They arent the same on every load.
I can get the ID assigned to a control with <%=TxtInvoiceAddress2.ClientID%> but I need to get the name to set the rule up.
Hope someone can help me figure out a way to setup JQuery rules to .Net Controls