javascript - radio button name change for validation validation -
i want change radio button name sex1, sex2 validation.but how can add value of i
for(i=1;i<=no_applicant;i++) { var sex = document.edu.sex+i+; (var j=0; j<sex.length; j++) { if (sex [j].checked) break; } if (j==sex.length) { alert("sex field "+i+" applicant cannot leave blank"); return false; } }
use e.g. document.edu["sex" + i].
in javascript,foo.bar convenient shorthand foo["bar"] works when key literal string matches form of identifier name. more complicated, use bracket form.
Comments
Post a Comment