• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

custom validator to check if IsDate works in IE but does not fire in firefox

I have a textbox with a custom validator to check if the users input is a date format or can be converted to a date. I am using the IsDate() function for clientside validation as well as serverside validation. (see code snipper below). It works fine in IE. when I type in some alpha numeric chracters the custom validator fires and show a message in the ValidationSummary  "this is not a valid date". In Firefox is does not do that. Please advice what am I doing wrong here. Thanks.
In the master page:
    <script type="text/vbscript">
    Function ValidateDate(source,args)
        if not IsDate(args.Value) then
            args.IsValid = False
        Else
            args.IsValid = True
        End if
     End function
    </script>
 
The custom validator:
    <asp:CustomValidator ID="CustomValidator1" runat="server"
        ControlToValidate="CheckInCheckOut" ErrorMessage="Date is not valid" 
        ClientValidationFunction="ValidateDate" Display="None">
    </asp:CustomValidator>
 
Code behind the web page:
    Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
        If Not IsDate(args.Value) Then
            args.IsValid = False
        Else
            args.IsValid = True
        End If
    End Sub

Open in new window

0
PdeLorme
Asked:
PdeLorme
1 Solution
 
PdeLormeAuthor Commented:
I have found in the meantime an other way to solve this with compare validator and its works fine. Thanks.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now