This is a discussion on checkbox validation within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; hi, how to validate checkbox using javascript... advance thanks, Rajkumar...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| hi rajkumar, case1: <script language="javascript" type="text/javascript"> function check() { if (document.Form1.chk1.checked == true) alert("Checked"); else alert("Not Checked"); } </script> case2: <script language="javascript" type="text/javascript"> function check() { if (document.getElementById("chkId").checked == true) alert("Checked"); else alert("Not Checked"); } </script>
__________________ ....................... Thanks, Venkatbi... |
| |||
| Hi, I hope that, this post will clear ur doubts Code: <SCRIPT TYPE="text/javascript" >
function checkCheckBoxes()
{
if (document.frmTest.CHKBOX_1.checked == false &&
document.frmTest.CHKBOX_2.checked == false &&
document.frmTest.CHKBOX_3.checked == false)
{
alert ('You didn\'t choose any of the checkboxes!');
return false;
}
else
{
return true;
}
}
</SCRIPT>
<form onsubmit="return checkCheckBoxes();" action="">
<input type="checkbox" name="CHKBOX_1" value="1">1</p>
<input type="checkbox" name="CHKBOX_2" value="2">2</p>
<input type="checkbox" name="CHKBOX_3" value="3">3</p>
<input type="submit" value="Submit!" />
</form>
__________________ Krishnakumar.S Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily |
| |||
| hi rajkumar, To check multiple checkbox... function funCheck() { vTmp1=document.myform.getElementsByTagName("checkb oxName"); vInLen=vTmp1.length; for(vI=0;vI<vInLen;vI++) { vRes[vI]=vTmp1.item(vI).getAttribute('checked') if(vRes[vI]==true) { alert("true"+vRes[vI]) } else { alert("false"+vRes[vI]) } } }
__________________ ....................... Thanks, Venkatbi... |
| |||
| <html> <head> <script type="text/javascript"> function validate(form) { if (!document.form1.sex[0].checked && !document.form1.sex[1].checked) { alert("Please Select Sex"); return false;} if(!document.form1.agree.checked){alert("Please Read the guidelines and check the box below"); return false; } return true; } </script> <body> <table border='0' width='50%' cellspacing='0' cellpadding='0' > <form name=form1 method=post action=action_page.php onsubmit='return validate(this)'> <input type=hidden name=todo value=post> <tr bgcolor='#ffffff'><td align=center > <font face='verdana' size='2'><b>Sex</b> <input type=radio name=sex value='male'>Male </font> <input type=radio name=sex value='female'> <font face='verdana' size='2'>Female</font> </td> </tr> <tr> <td align=center bgcolor='#f1f1f1'> <font face='verdana' size='2'> <input type=checkbox name=agree value='yes'>I agree to terms and conditions </td></tr> <tr bgcolor='#ffffff'> <td align=center > <input type=submit value=Submit> <input type=reset value=Reset> </td> </tr> </table></form> </body> </head> </html> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| count the time in seconds that a checkbox is really checked | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 02-13-2008 10:16 PM |
| I have multi checkbox in my form... | gk_cloud | PHP Programming | 2 | 10-22-2007 06:31 AM |
| How to show a table when click a checkbox? | S.Vinothkumar | HTML, CSS and Javascript Coding Techniques | 6 | 10-12-2007 07:02 AM |
| client side validation for checkBox using ServerControlButton | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 09-26-2007 11:18 AM |
| How to postback the checkbox value in treeview when each time it is checked ? | bluesky | ASP and ASP.NET Programming | 0 | 07-16-2007 12:24 AM |