CompareValidator not causing validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rrocket
    New Member
    • Aug 2007
    • 116

    CompareValidator not causing validation

    I keep getting this error:
    String was not recognized as a valid DateTime.
    when I try to sumbit a form with this
    [code=html]
    <asp:TextBox ID="tbDate" runat="server"> </asp:TextBox>
    <cc1:CalendarEx tender id="bdplPickupD ate" runat="server" TargetControlID ="tbDate" Format="MM-dd-yyyy" PopupButtonID=" tbDate">
    </cc1:CalendarExt ender>

    <asp:CompareVal idator ID="cvDate"
    ControlToValida te="tbDate"
    Display="none"
    Text="Invalid Date!"
    Operator="DataT ypeCheck"
    Type="Date"
    Runat="Server"
    ErrorMessage="Y ou must provide a valid date!"
    ></asp:CompareVali dator>
    <cc1:ValidatorC alloutExtender runat="server" ID="vceDate" TargetControlID ="cvDate">
    </cc1:ValidatorCa lloutExtender>
    [/code]

    The cc1 stuff is Ajax, but it still does the same thing whether it is there or not. The compare validator should fire and keep the form from submitting if the date is invalid, but it keeps throwing the error (from above).

    Basically I am just trying to check for a valid date.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by rrocket
    I keep getting this error:
    String was not recognized as a valid DateTime.
    when I try to sumbit a form with this
    [code=html]
    <asp:TextBox ID="tbDate" runat="server"> </asp:TextBox>
    <cc1:CalendarEx tender id="bdplPickupD ate" runat="server" TargetControlID ="tbDate" Format="MM-dd-yyyy" PopupButtonID=" tbDate">
    </cc1:CalendarExt ender>

    <asp:CompareVal idator ID="cvDate"
    ControlToValida te="tbDate"
    Display="none"
    Text="Invalid Date!"
    Operator="DataT ypeCheck"
    Type="Date"
    Runat="Server"
    ErrorMessage="Y ou must provide a valid date!"
    ></asp:CompareVali dator>
    <cc1:ValidatorC alloutExtender runat="server" ID="vceDate" TargetControlID ="cvDate">
    </cc1:ValidatorCa lloutExtender>
    [/code]

    The cc1 stuff is Ajax, but it still does the same thing whether it is there or not. The compare validator should fire and keep the form from submitting if the date is invalid, but it keeps throwing the error (from above).

    Basically I am just trying to check for a valid date.
    I've actually never used a CompareValidato r before...but since you're using the Ajax.NET Toolkit, have you considered using the MaskedEditExten der or the MaskedEditValid ator?

    -Frinny

    Comment

    Working...