469,344 Members | 6,163 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

How to get the name, class or id of a field in a form if serialize() in javascript?

288 256MB
Hello friends. . ! I want to know if how to get the name, class or id of a textfield in a form if we used the serialize() function in javascript. .
we have this form
Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="javascript:;" id="form">
  2. <input type="text" name="field_a" class="required" id="field_a"><br>
  3. <input type="text" name="field_b" class="required" id="field_b"><br>
  4. <input type="text" name="field_c" class="required" id="field_c"><br>
  5. <input type="submit" value="save" id="save">
  6. </form>
and here is our javascript or jquery.
Expand|Select|Wrap|Line Numbers
  1. $('#save').click(function(event){
  2. var data = $("form#form").serialize();
  4. //code to know the field's class, name or id,
  5. //alert(data.fieldname);
  6. });
How can I code to know the textfields class, name or id for a field and out put all the fields with a class="required"?
any suggestion are appreciated, thank you and advance. :)
May 29 '14 #1
2 2150
8,652 Expert Mod 8TB
the answer is off the top of the jQuery documentation:
The .serialize() method creates a text string in standard URL-encoded notation.
May 30 '14 #2
288 256MB
I already solved this problem, , thanl you to your reply. :)
May 31 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Frederik S | last post: by
17 posts views Thread by Jonah Olsson | last post: by
3 posts views Thread by Jon | last post: by
6 posts views Thread by magix | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.