Friday, June 17, 2011

CheckBox Validation: JavaScript

CheckBox Validation: JavaScript


<script type="text/javascript" language="javascript">
function ValidateCheckBox(src, args)
{
if (document.getElementById('<%=chk_Terms.ClientID %>').checked == false)
{
alert("Please check Terms & Conditions before continuing.");
//return false;
args.IsValid = false;
}
}
------------------------------------------------

<asp:CheckBox ID="chk_Terms" runat="server" CssClass="arial11normalblack" Text="I agree to the Terms & Cconditions" />

<asp:CustomValidator ValidationGroup="submit" ID="cv_Checkbox" runat="server" ClientValidationFunction="ValidateCheckBox"
Display="None" SetFocusOnError="True">*</asp:CustomValidator>

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More