Problem with CompareValidator control

Discussion in 'ASP .Net Web Controls' started by Andres Aguiar, Jul 28, 2004.

  1. Hi,

    I'm using the CompareValidator with a DateTime field using the dd/MMM/yyyy
    format (example "07/Jun/2004" ) .

    The compare validator seems not work with this format. It always says that
    the date is invalid.

    I'm using the CompateValidator with Operator= "DataTypeCheck" and
    Type="Date".

    <asp:CompareValidator runat="server" id="ValidateDate"
    ControlToValidate="InvoiceDate" Operator="DataTypeCheck" Type="Date"
    ErrorMessage="invalid date" ></asp:CompareValidator>

    What am I missing?

    Thanks

    Andres
    Andres Aguiar, Jul 28, 2004
    #1
    1. Advertising

  2. Hi Andres,

    As for the Validation Date problem on using the CompareValidator control.
    This is because the CompareValidator's support on date validtion only
    contain some basic date formats such as:
    mm/dd/yyyy or dd/mm/yyyy ... and not all those formats we can cover.
    Also, we can't force it to validate regarding on a specified format.
    And as for your scenario, I think the CustomValidator or RegularExpression
    Validator control maybe suitable. And here is a former thread discussing on
    the similiar problem, you may have a look:

    http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=iu91ie8YEHA.3120%
    40cpmsftngxa06.phx.gbl&rnum=1&prev=/groups%3Fq%3Dasp.net%2520date%2520valida
    tion%2520regex%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg

    Also, below are some regex for validting date/time resources which maybe
    useful if you'll use the RegularExpressionValidator to check the date input:
    #Regex Lib for DAte/Times
    http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=5&categoryId=5

    #RegEx Short Date Validation
    http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=474

    Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    Steven Cheng[MSFT], Jul 29, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Maia
    Replies:
    2
    Views:
    5,487
    Peter Blum
    Nov 18, 2004
  2. Chris Leffer

    DataTypeCheck in comparevalidator control

    Chris Leffer, May 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    6,027
  3. Groove
    Replies:
    0
    Views:
    356
    Groove
    Aug 16, 2006
  4. VancouverMike
    Replies:
    0
    Views:
    599
    VancouverMike
    Apr 11, 2008
  5. pc
    Replies:
    0
    Views:
    115
Loading...

Share This Page