Hi Programmers,
I just faced little difficult to validate radio box element using java script but i think most of the developer had done lot of script on radio box validation.
For my sake i am posting blog on validation on radio box.
function valButton(btn) {
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
if (btn[i].checked) {cnt = i; i = -1;}
}
if (cnt > -1) return btn[cnt].value;
else return null;
}
function valForm(form) {
var btn = valButton(form.group1);
if (btn == null) alert('No radio button selected');
else alert('Button value ' + btn + ' selected');
}
Monday, June 14, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment