This topic is locked
[SOLVED]

 Validate date fields (reopened)

3/22/2012 6:48:40 PM
ASPRunnerPro General questions
A
andolo author

Dear Sirs,
I posted this question earlier and got a good reply from you. Here is the question and the reply:
Question: 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-date? Or a higher From-date than End-date?
Answer: As a simplest solution you can use BeforeAdd event for this purpose.

Here is the sample code: http://xlinesoft.com...n_enddate.htm
However, when i tried this code, nothing happens. It is still possible to enter a lower end-date (Slutdatum) than start-date (Startdatum). What could be wrong?

The code is as follows, entered as a Before record updated event:
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

Sergey Kornilov admin 3/22/2012

Remove BeforeEdit=true from the end of your event code. Let us know if this helps.

A
andolo author 3/23/2012

I tried it, but unfortunately it is still possible to add an end-date that are lower than the start-date.

A
andolo author 3/23/2012

... But I tried once more, and now it worked! Must have to do with the build the first time.