Tuesday, May 8, 2012

JavaScript for Clientside validation for asp.net Single-CheckBox using CustomValidator

<script  language="javascript" type ="text/javascript" >
function checkAgreement(source, args)
{
var elem = document.getElementById("cbxPDCheque");
if (elem.checked)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
</script>
 
<asp:CheckBox ID="cbxPDCheque" runat="server" AutoPostBack="True" Text="PD Cheques" />
<asp:CustomValidator ID="CustomValidator1" runat="server" EnableClientScript ="true"
ErrorMessage="Select PD Cheques." ClientValidationFunction ="checkAgreement" >*</asp:CustomValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" />
<asp:Button ID="Button1" runat="server" Text="Button" />
 
http://www.codeproject.com/Questions/188889/JavaScript-for-Clientside-validation-for-asp-net-S  

No comments:

Post a Comment