Hi
I need to validate whether the checkbox is checked or not on a button onclientclick event in asp.net
This is my asp:button
<asp:Button ID="btnNext" runat="server" Text="Proceed to Next >" OnClientClick="ValidateOptions()" OnClick="btnNext_Click" />
I want to check the validation in 'onClientclick' event and after the validation i want to execute the code in 'OnClick' event.
The same javascript funtion is triggered and worked fine when i gave only an alert message in it but when i use it for checkbox validation,it is not working.
<script type="text/javascript">
function ValidateOptions() {
if(document.getElementById('chkQ8Option6').checked {
alert("CheckBox checked.");
} else {
alert("CheckBox not checked.");
}
}
</script>
I also tried this below code and usesubmitbehaviour property..nothing works and i think there is problem with the checkbox code.
<asp:Button ID="btnNext" runat="server" Text="Proceed to Next >" OnClientClick="if (!ValidateOptions()) { return false;};" OnClick="btnNext_Click" />
Could you please help me?