Date Validation

  • ricmcdonald
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 85
  • Thank you received: 0

ricmcdonald created the topic: Date Validation

Down under we use the date format %d-%m-%Y is there a validation script to prevent dates before today being entered

also when setting a begin date and an end date is there a way of preventing an end date before a begin date
Thanks
#231820
  • Posts: 1573
  • Karma: 48
  • Thank you received: 201

mihaela replied the topic: Date Validation

Hello,


Here is the validation script that will check whether the date is in the future.
function ff_CALENDARITEMNAME_validation(element, message)
{
    
     if(element.value.split("-").length != 3){return message == '' ? element.name+" faild in my test.n" : message}
 
          var vDate = new Date(Number( element.value.split("-")[2]),Number(element.value.split("-")[1]-1),Number(element.value.split("-")[0]),0,0,0).getTime();
 
 
     var today = new Date();
 
     today.setHours(0);
     today.setMinutes(0);
     today.setSeconds(0);
     today.setMilliseconds(0);
     today = today.getTime();
 
     if(vDate < today)
     {
          if (message=='') message = element.name+" faild in my test.n";
          return message;
     }
     return '';
} // ff_CALENDARITEMNAME_validation
NOTE: Replace CALENDARITEMNAME with the Name of calendar element.

Regarding the preventing end date being after the start date, please take a look at the following solution crosstec.org/en/forums/1-forums/123319-b...nd-datum.html#222360 .

Let me know whether you've managed to set this for your form and whether it works as you wanted.

Regards,

Mihaela
#231833
  • Posts: 3
  • Thank you received: 0

igi replied the topic: Date Validation

hi mihaela, many thanks for the script.
question:
We have a form with start and end date incl. time for a reservation. (bowling center)
is the following possible?
The goal is that the customer the start date resp. time can not specify 4 hours before the current server time?

thank you for your help
igi
#233106
  • Posts: 1573
  • Karma: 48
  • Thank you received: 201

mihaela replied the topic: Date Validation

Hello again,

I'm glad to help you.
I am not sure if I understood correctly what you want to achieve so I will check.
Does the start date also collects the time? Any you don't want the time to be before 4 hours after filling in the form?

I that is the case, please create a package with your form as explained here crosstec.org/en/support/online-documenta...ted/94-packages.html , zip it and send it here as an attachment so I can see how exactly the time is collected.

Regards,

Mihaela
#233124
  • Posts: 3
  • Thank you received: 0

igi replied the topic: Date Validation

Hi, did you get the package? I have already sent it alnge. as security again the package as a side dish. Thank you for your help.
igi
#233312
Attachments:
  • Posts: 1573
  • Karma: 48
  • Thank you received: 201

mihaela replied the topic: Date Validation

Hello again,

I see now, you have a element "Datum" that collects that start date and a select list element that collects start time. The start time is possible only after noon.

You wrote " the start date resp. time can not specify 4 hours before the current server time"

Regards,

Mihaela
#233346
Moderators: ForumSupporttomeperica
Time to create page: 0.047 seconds

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here