input text array validation 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

input text array validation in jquery

Post by pcoder »

Hi All,
I am using jquery to validate the form. But i got a problem to validate completely. Somewhere i have an element like:
<select name="relation_cd[]" id="relation_cd">
</selelct>
<select name="relation_cd[]" id="relation_cd">
</selelct>
Which comes from database dynamically.
Is there any technique to validate such kind of element in jquery?
I didn't find the way to validate. I am new to jquery even i don't know how to add the custom validation function so that i can validate the form completely.
Hope, i will get some suggestion from you guys.

Thanks
charlestide
Forum Newbie
Posts: 3
Joined: Fri Apr 17, 2009 1:21 am

Re: input text array validation in jquery

Post by charlestide »

i have not found any rule for your validator, so i can just tell you how to select those elements.

Code: Select all

 
$('select[@name^=relation_cd]').change(function(){
//here is your validating code
});
 
the function will occur when all of SELECT tags that NAME start with relation_cd. but i have no test for this. if it not work, may be you could add your own attribuates to the SELECT, such as <select name="relation_cd[]" use="validator">

my english is poor, hope you can understand what i said
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: input text array validation in jquery

Post by pickle »

Your code is invalid. You can't have 2 elements with the same ID. ID must be unique.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: input text array validation in jquery

Post by pcoder »

Thanks for your reply guys.
Your code is invalid. You can't have 2 elements with the same ID. ID must be unique.
Currently, ID is use less, it used name for the validation.
I couldn't validate it using jquery. Still finding the way to validate it.
Thanks
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: input text array validation in jquery

Post by kaszu »

From jQuery documentation
Note: In jQuery 1.3 [@attr] style selectors were removed (they were previously deprecated in jQuery 1.2). Simply remove the '@' symbol from your selectors in order to make them work again.
Correct selector will be

Code: Select all

select[name^=relation_cd]
Post Reply