This topic is locked
[SOLVED]

 Rules on dates

6/13/2019 7:56:43 PM
ASPRunner.NET General questions
O
Onofre author

Good night

I need to put a rule on inserting dates.

Example: The start date can not be less than the current date.

Can you help me?

T
Tim 6/14/2019

You can do this in the "Before record added" event. Here is an example from the help file:
https://xlinesoft.com/asprunnernet/docs/check_if_start_date_is_ealier_than_enddate.htm
You could also do it in javascript if you wanted it to happen as they change the field.
Good luck.

Tim

jadachDevClub member 6/14/2019
DateTime dt1 = DateTime.Parse(values["StartDate"].ToString());

DateTime dt2 = DateTime.Today;
if (dt1.Date < dt2.Date)

{

message = "Start date cannot be less than current date";

return false;

}

else

{

return true;

}
admin 6/14/2019

In version 10.2 we implemented Date Control API that makes things like this easier.

https://xlinesoft.com/blog/2019/06/13/version-10-2-of-phprunner-asprunner-net-and-asprunnerpro-is-here/
We will have documentation on this topic available in a couple of days. For this specific task you can use the following code in Javascript OnLoad event:

var ctrl = pageObj.getControl("DateField");

ctrl.setAllowedInterval( Date.now() , null );