PdeLorme
asked on
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.