Jquery: elements value is not coming correct
I trying to get the all input elements having name="choices" before
submit. And i want to check the values of those elements before submiting
the form . The problem is instead of getting the 0 ,1 ,2 which is values
of elements i'm getting undefined (3 times).
form
<form action="/check" method="post" id="mform1" >
<div id="id_poll_choices" >
A). <input type="text" id="id_ch" name="choices"
value="0"><br>
B). <input type="text" id="id_ch" name="choices"
value="1"><br>
C). <input type="text" id="id_ch" name="choices"
value="2"><br>
</div>
<input type="submit" id="id_submit" value="Submit"/>
</form>
jquery
$('#mform1').submit(function(){
$( "input[name*='choices']" ).each(function(index, elm){
alert(elm.val)
});
});
alert showing undefined.
what could be the issue here ?
No comments:
Post a Comment