ID Instead of Name in jQuery

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

ID Instead of Name in jQuery

Post by pcoder »

Hi All,
Is it possible to use the id attribute of an element instead of name attribute while defining a validation rule in jQuery?
If yes, What would I have to do? I hope , you guys have some view on it.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: ID Instead of Name in jQuery

Post by Benjamin »

Code: Select all

 
$("#element_id").blah
 
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: ID Instead of Name in jQuery

Post by pcoder »

Thanks astions for the quick response.
Can I do the validation by using ID instead of Name attribute in jQuery?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: ID Instead of Name in jQuery

Post by Benjamin »

Form validation? Yes
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: ID Instead of Name in jQuery

Post by pcoder »

Can you please give some idea on this?
I think I have to change somewhere in jquery validate plugin file. right?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: ID Instead of Name in jQuery

Post by Benjamin »

Have a look at the manual. From what I see it already does use the element ID's.

http://docs.jquery.com/Plugins/Validation
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: ID Instead of Name in jQuery

Post by pcoder »

I have gone through the manual and used validation in some of the projects. jQuery use Name instead of ID for validation.
But in one form , I have the feature of Add More, Which increments the ID attribute dynamically but the name attribute is same.
The reason for making name attribute same is to get the posted value in an array.
But here the validation rule is failed.
I tried a lots of way to do it. :(
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: ID Instead of Name in jQuery

Post by Benjamin »

Yeah I don't know what to tell you. I wouldn't be able to answer that without studying the documentation. From what I did see however, it was using the ID. Maybe someone else can help.
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: ID Instead of Name in jQuery

Post by pcoder »

Anyway, thanks for your comments.:) :)
Post Reply