-
javascript checkbox validation
hi.... i used this following code to validate form. in the form there are 4 radio buttons with same name and for each radio there are two or three checkboxes. by default checkboxes are disabled. if user clicks on a radio then checkboxes related to that are enabled, if user clicks different radio then previous redio's checkboxes are disabled and new clicked radio's checkboxes are enabled.
the following code is working fine but i have to call this function for each radio's onchange event. otherwise it doesnt work for single radio - if i call it for one radio and clicked that radio it works first time and enables the checkboxes but when i click second time on it the checkboxes are disabled.
function enablecheck()
{
if (document.test.category[0].checked)
{
document.test.sc1.disabled=false;
document.test.sc2.disabled=false;
}
else
{
document.test.sc1.checked=false;
document.test.sc1.disabled=true;
document.test.sc2.checked=false;
document.test.sc2.disabled=true;
}
if (document.test.category[3].checked)
{
document.test.art1.disabled=false;
document.test.art2.disabled=false;
}
else
{
document.test.art1.checked=false;
document.test.art1.disabled=true;
document.test.art2.checked=false;
document.test.art2.disabled=true;
}
}
-
-
See http://www.twey.co.uk/?q=forms -- modify the showEl and hideEl functions defined at the top of the setupDependencies() function to simply disable the element.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks