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. .
example:
we have this form
and here is our javascript or jquery.
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. :)
example:
we have this form
Code:
<form method="post" action="javascript:;" id="form"> <input type="text" name="field_a" class="required" id="field_a"><br> <input type="text" name="field_b" class="required" id="field_b"><br> <input type="text" name="field_c" class="required" id="field_c"><br> <input type="submit" value="save" id="save"> </form>
Code:
$('#save').click(function(event){
var data = $("form#form").serialize();
//code to know the field's class, name or id,
//alert(data.fieldname);
});
any suggestion are appreciated, thank you and advance. :)
Comment