TOPIC:

2 Calendar-Formfields - 2.tes muss immer größer sein als 1.tes 5 days 7 hours ago #256877

  • Topic Author
  • Mister.Miracle
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 125
  • Karma: 1
  • Thanks: 1
Hallo zusammen,

ich habe 2 Calendar-Fields für die Auswertung von Urlauben in einem Formular
1.) Name: UrlaubBeginn
2.) Name: UrlaubEnde

Format: dd.mm.yyyy

ich möchte bei Feld UrlaubEnde eine Fehlermeldung ausgeben, wenn Date(UrlaubEnde) < Date(UrlaubBeginn) ausrechnet.

Fehlermeldungen generieren kann ich... aber funktioniert dies auch, wenn ich Element-Values aus einem anderen FormField nutzen möchte?
Wie kann ich das herstellen?
function ff_UrlaubsEnde_validation(element, message)
{
    if (KALENDER_BERECHUNG) {
        if (message=='') message = element.name+" faild in my test.\n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';
} // ff_UrlaubsEnde_validation


Diese Kalenderberechnung Ende < Anfang muss ich noch machen... aber wie :-)???

Please Log in or Create an account to join the conversation.

2 Calendar-Formfields - 2.tes muss immer größer sein als 1.tes 4 days 23 hours ago #256898

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 4796
  • Karma: 3
  • Thanks: 345
Hi,

give me some time to test this.

I was not here few days so I am in crowded with support cases, but I will try to finish this today.

If there is no answer of mine please remind me :)

Thanks for understanding



UPDATE:
please go to end date->Properties->Validation->check Custom and put this:
function ff_enddateelement_validation(element, message)
{
   // Checking if the entered date is in right format
   var pattern =  /[0-3][0-9]\.(0|1)[0-9]\.(19|20)[0-9]{2}$/;
   if(pattern.test(element.value))
   {
      var date_array = element.value.split('.');
      var day = date_array[0];
 
      // Attention! Javascript consider months in the range 0 - 11
      var month = date_array[1] - 1;
      var year = date_array[2];
 
      // This instruction will create a date object
      startDate = new Date(year,month,day);
 }
    
   var calend2=ff_getElementByName('startdateelement').value.split(".");
   var d2= new Date(calend2[2], calend2[1]-1, calend2[0]); 
   var dan=d2.getDate();
   var mj=d2.getMonth();
   var god=d2.getFullYear();
   var end=new Date(god,mj,dan);
   
   if (startDate < end) {
       if (message=='') message = "End date can't be greater then start date .\n"
       ff_validationFocus(element.name);
       return message;
   } // if
return '';
  
} // ff_enddateelement_validation

Please replace:
enddateeleemnt with name for your calendar for end date (not title)
startdateelement with name of your calendar for start date (not title)

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Last edit: Post by tihana.krivic. Reason: added solution for this

2 Calendar-Formfields - 2.tes muss immer größer sein als 1.tes 3 days 10 hours ago #257094

  • Topic Author
  • Mister.Miracle
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 125
  • Karma: 1
  • Thanks: 1
okay, i understand your code, but is it not possible to test / check 2 vars (format DATE) so i could test in this way:
if (startdatum > enddatum) {
   do something 
} else {
   echo "everything okay"
}

Please Log in or Create an account to join the conversation.

2 Calendar-Formfields - 2.tes muss immer größer sein als 1.tes 3 days 1 hour ago #257101

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 4796
  • Karma: 3
  • Thanks: 345
Hi,

for this we need actionscripts, but it is not available in the resposnive calendar.

So, with this validation code if someone select start date 7.4 and end date 6.4, on submit there will be error message:
if (startdate < enddate) {
//show error message
}
return '';
//else everything is ok

I hope I didn’t misunderstand your first message :)

Regards,
Tihana

Please Log in or Create an account to join the conversation.

2 Calendar-Formfields - 2.tes muss immer größer sein als 1.tes 1 day 7 hours ago #257263

  • Topic Author
  • Mister.Miracle
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 125
  • Karma: 1
  • Thanks: 1
Thank you...

first of all it works fine...
but before create validation code to the field... the form could without entering data clicked to next page and then there was an error-message list of all field-errors.

now i can click on next page (if no data is entered!) and nothing happend. Maybe i have to validate both (empty Entry AND endDate < startDate)?

I could work with it in this way... but i dont understand? And for the next time i would be able to understand such problems or behaviours of the form-elements.

Thank you for helping.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.048 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

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!