TOPIC:

Calculate Age... 2 months 1 week ago #244845

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

if you select a date from the calendar (e.g. July 14, 2018) in the textfield you should get years->2 years.

Regards,
Tihana

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

Calculate Age... 2 months 1 week ago #244894

  • Topic Author
  • jvkeller
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 111
  • Thanks: 0
I have everything in place and it's not working right. At one point it was off by 1 year, but now it's not working at all... sigh. not having good luck this week!

I also need to tweek the format for mm/dd/yyyy,

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

Last edit: Post by jvkeller.

Calculate Age... 2 months 1 week ago #244896

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

did you do everything as in the attached form?
If you want you can post your form here, so I can take a look

Regards,
Tihana

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

Last edit: Post by tihana.krivic.

Calculate Age... 2 months 1 week ago #245055

  • Topic Author
  • jvkeller
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 111
  • Thanks: 0
Here's the form, been a busy week.

I'm not even sure what I have as far as code in their right now. I did try to adjust for mm/dd/yyyy at one point. I looked up a new regx expression but that didn't seem to work either.

By the way, are the scripts in php or js?
Attachments:

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

Calculate Age... 2 months 6 days ago #245087

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

your year calculation doesn't work because you didn't change the form name in init.script (you left the form name as birthday_form). I changed it, and now it works.

File Attachment:

File Name: age.zip
File Size:15 KB


Scripts are in js.

This is what the code looks like now:
function ff_adoptablepets_init()
{
setInterval('showage()',500);
}

function showage(){
        var one_year=1000*60*60*24*365;
        var date1 = new Date();
        
        var dob= ff_getElementByName('birthday').value;
        var tmp=ff_getElementByName('birthday').value.split("/");
        var date2=new Date(tmp[2],tmp[1]-1,tmp[0]);
       
       var pattern= /[0-3][0-9]\/(0|1)[0-9]\/(19|20)[0-9]{2}/;    //Regex to validate date format (dd/mm/yyyy)
        if (pattern.test(dob)) {
            var y1 = date1.getTime(); //getting current year
            var y2 = date2.getTime(); //getting dob year
            var diff=Math.floor((y1-y2)/one_year);
            
            ff_getElementByName('age2').value=diff;    
        }
}

Also, if you need date format: mm/dd/yyyy change format in your responsive calendar, and change regex for validate date.

Let me know if you need more help

Regards,
Tihana
Attachments:

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

Last edit: Post by tihana.krivic.

Calculate Age... 2 months 5 days ago #245243

  • Topic Author
  • jvkeller
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 111
  • Thanks: 0
Seems to be working good now!

Thank you much!

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

Moderators: ForumSupport
Time to create page: 0.045 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!