This topic is locked
[SOLVED]

 Validate date picker fields

3/19/2012 10:09:17 AM
ASPRunnerPro General questions
A
andolo author

I have an Add page where users can enter datespans för new public events they events they want to announce. They choose From-date and End-date by datepickers. But is it possible to validate the fields so that the users cannot enter a lower End-date than Start-startdate? Or a higher From-date than End-date?

Sergey Kornilov admin 3/19/2012

As a simplest solution you can use BeforeAdd event for this purpose.

Here is the sample code: http://xlinesoft.com/asprunnerpro/docs/check_if_start_date_is_ealier_than_enddate.htm

A
andolo author 3/19/2012



As a simplest solution you can use BeforeAdd event for this purpose.

Here is the sample code: http://xlinesoft.com/asprunnerpro/docs/check_if_start_date_is_ealier_than_enddate.htm


Thanks! /Anders

A
andolo author 3/22/2012

Dear Sergey,
I was unlucky with the Event code! I made an event Before record updated and put this code into the Description:
if CDate(values("Startdatum"))>CDate(values("Slutdatum")) then

message = "Error"

BeforeEdit = False

else

BeforeEdit = True

end if
' Place event code here.

' Use "Add Action" button to add code snippets.
BeforeEdit=true
The post is saved, but it is still possible to make end-date (Slutdatum) lower than start-date (Startdatum)... That is, the check does not happen.
/Anders