Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dynamic CheckBox validation in javascript

843840Jan 17 2008 — edited Jun 24 2008
i have a checkbox generated dynamically in a form .

I need to validate to check whether atleast one check box is clicked .

i can validate when there is more than one checkbox generated . But i cannot if the form contains only one checkbox
Below is the js .

function dothecheck()
{

var checkedvalue=new String();
var checkVal=document.frm.closecase;
var checklength=checkVal.length;
var val=0;
//alert(checklength);
for(var i=0;i<checklength;i++)
{
if(checkVal.checked==true)
{
// alert("checked");
document.frm.submit();
}
else
{
val=val+1;
// alert(val);
}

}
if(val==checklength)
{
// alert(val);
alert("Please check a checkbox");
}
else
{
document.frm.submit();
}

}

Somebody Help at this. plz
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2008
Added on Jan 17 2008
13 comments
783 views