Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Date compare validation Problem

Date compare validation Problem

Scheduled Pinned Locked Moved ASP.NET
help
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prince Patel
    wrote on last edited by
    #1

    Dear friends, Is it is possible using Custom validator to compare two dates in dd/MM/YYYY. hey donot using compare validator. if it is possible then give me solution ASAP with regard Hiren Patel Hiren Patel

    D 1 Reply Last reply
    0
    • P Prince Patel

      Dear friends, Is it is possible using Custom validator to compare two dates in dd/MM/YYYY. hey donot using compare validator. if it is possible then give me solution ASAP with regard Hiren Patel Hiren Patel

      D Offline
      D Offline
      David Flores
      wrote on last edited by
      #2

      Yes you can use a custom validator. In your aspx file add your custom validator as you would normally do except, DO NOT fill in the ControlToValidate attribute. In your codebehind file (e.g. aspx.vb) add your ServerValidate message to do your testing of the dates. Here is some quick code txtStartDate and txtEndDate are text boxes Private Sub customDate_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles customDate.ServerValidate Dim startDate As Date = Convert.ToDateTime(me.txtStartDate.Text.Trim) Dim endDate As Date = Convert.ToDateTime(me.txtEndDate.Text.Trim) 'make sure the start date is before the end date args.IsValid = (startDate < endDate) End Sub Hope this helps...you also might want to put a Try/Catch block to protect against bad input/conversions. David

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups