Is my validation code correct?

Results 1 to 2 of 2

Thread: Is my validation code correct?

  1. #1
    Webgirl Guest

    Default Is my validation code correct?

    Here&#039s how I would do logic for dates on a form to make sure a stop date didn&#039t occur before a start date...<BR>&#060;%<BR>Dim StartDate, StopDate, TodaysDate<BR>StartDate = Request.Form("StartDate")<BR>StopDate = Request.Form("StopDate")<BR>TodaysDate = Date()<BR>If StartDate &#060; TodaysDate Then<BR>Response.Write "Project start date cannot be before today&#039s date."<BR>End If<BR>If StopDate &#060;= StartDate Then<BR>Response.Write "Project Completion date cannot be on or before Project Start Date."<BR>End If<BR>%&#062;<BR><BR>Here&#039s how I would do the valid date. I would use the IsDate Function something like this....<BR><BR>&#060;%<BR>Function IsDate(StartDate, StopDate)<BR>StartDate = Request.Form("StartDate")<BR>StopDate = Request.Form("StopDate")<BR>If IsDate(request.form("StartDate")) and IsDate(request.form("StopDate")) Then<BR>&#039Submit to value to your database or whatever you want to do with it.<BR>Else<BR>Response.Write "Invalid date. Date format is mm/dd/yyyy."<BR>End If<BR>End Function<BR>%&#062;<BR>Am I doing this correctly?<BR>

  2. #2
    Dhana Guest

    Default RE: Is my validation code correct?

    You r not checking for the date difference, after using Isdate fns. that to be used if the date comparison is required

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts