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

Posted on 2008-11-11
Last Modified: 2012-05-05
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


            args.IsValid = True

        End if

     End function


The custom validator:

    <asp:CustomValidator ID="CustomValidator1" runat="server"

        ControlToValidate="CheckInCheckOut" ErrorMessage="Date is not valid" 

        ClientValidationFunction="ValidateDate" Display="None">


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


            args.IsValid = True

        End If

    End Sub

Open in new window

Question by:PdeLorme
    1 Comment

    Accepted Solution

    I have found in the meantime an other way to solve this with compare validator and its works fine. Thanks.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Building “do-it-yourself” web sites has become an epidemic. There are so many blogs, web sites and even books that "teach" you how to build your web site in a few extremely simple and easy steps. Building a web site has become easier than boiling an…
    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    The viewer will learn how to dynamically set the form action using jQuery.
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now