Page 1 of 1

ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 12:29 am
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.

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 12:33 am
by Benjamin

Code: Select all

 
$("#element_id").blah
 

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 1:00 am
by pcoder
Thanks astions for the quick response.
Can I do the validation by using ID instead of Name attribute in jQuery?

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 1:08 am
by Benjamin
Form validation? Yes

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 1:32 am
by pcoder
Can you please give some idea on this?
I think I have to change somewhere in jquery validate plugin file. right?

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 1:41 am
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

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 1:53 am
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. :(

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 2:32 am
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.

Re: ID Instead of Name in jQuery

Posted: Tue Sep 01, 2009 3:45 am
by pcoder
Anyway, thanks for your comments.:) :)