Click here to Skip to main content
16,021,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have one web page that contains two radio buttons and few other controls.
So,for that i wrote a function in javascript for validations.If my radio buttons are visible on page it will work fine.

But,For few users those radio buttons should not be visible so, if i kept as Visible false radio buttons are not rendering to page source then other validations are also skipping.So,In this kind of situation i need to check whether my page has radio buttons are not. so How to check my page has radio buttons are not in javascript.

Thanks & Regards
Avinash
Posted

1 solution

C#
var rbtNew = document.getElementById('rbtNew');
 var rbtOld = document.getElementById('rbtOld');

C#
if (rbtNew != null && rbtOld != null) {
                if (rbtNew.checked == false && rbtOld.checked == false) {
                    alert("our Alert Message ");
                    return false;
                }
            }


In the above code rbtNew != null means radio button is exist in page source otherwise it will have null value.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900