Old style Custom Validators

4 comments

 

Basic Validators

<asp:RequiredFieldValidator ControlToValidate="Password" ErrorMessage="password is required" ValidationGroup="sign_up" Display="None" runat="server" />
 

Email Validator

<asp:RegularExpressionValidator ValidationGroup="sign_up" ControlToValidate="Email" ValidationExpression="(^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$)|email address" ErrorMessage="email address is not of the form name@domain.com" SetFocusOnError="true" runat="server"> 

 

Custom Validator:

 

<script type="text/javascript">
        function CheckPicture_ClientValidate(source, arguments) {
                var picId = '<%= PhotoUpload.ClientID %>_HiddenImageId';
                if ($('#' + picId).val() == '') {
                        $('#' + picId).focus();
                        arguments.IsValid = false;
                }
                else {
                        arguments.IsValid = true;
                }
        }
</script>
<asp:CustomValidator ClientValidationFunction="CheckPicture_ClientValidate" OnServerValidate="CheckPicture_Validate" ErrorMessage="you have not yet uploaded a photo" ValidationGroup="photo_info" Display="None" runat="server" />

 

Javascript that invalidates page

Reference: http://msdn.microsoft.com/en-us/library/aa479045.aspx#aspplusvalid_clientside

 

How to make a Checkbox Validator control properly

Here is the code for the skmValidator controls we use

http://www.4guysfromrolla.com/articles/092006-1.aspx 

To make this work you need:

AppCode/Controls/skValidators folder (with three files)

js/skmValidators/ folder (with one file)


Comments


Leave a Comment