Conditional Field If Less than 18 Years Old

  • multiweb
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

multiweb replied the topic: Conditional Field If Less than 18 Years Old

My email address is adrian@multiwebmarketing.co.uk, if you could send me an email I am more than happy to provide administrator access to the website, if you don't mind continuing to help.

Thanks
#236243
  • multiweb
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

multiweb replied the topic: Conditional Field If Less than 18 Years Old

Hi Mihaela,

Have you any idea what else could be causing the issue?
#236276
  • multiweb
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

multiweb replied the topic: Conditional Field If Less than 18 Years Old

Would you try sending me your form as a package to try please? Or even the full Joomla 3 database and website files?
#236278
  • Posts: 2359
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Conditional Field If Less than 18 Years Old

Hello,

After going through the form that you've sent me in the package once more, I've realized where is the issue.

As written in along the code suggested, that code will work for dates in format dd/mm/yyyy and you are using dd-mm-yyyy format in your form.

Therefore please replace your Initialization script with this one:
function ff_registration_init()
{
setInterval(calAge, 500);
} // ff_registration_init

function calAge(){
var dateBirth = ff_getElementByName('dobfield').value;
    var dobParts = dateBirth.split("-");
     var now = new Date();
  var dobParts = dateBirth.split("-");
  var dob = new Date(dobParts[2], (dobParts[1] - 1), dobParts[0]);
  
  var dobYear = dob.getFullYear();
  var dobMonth = dob.getMonth();
  var dobDay = dob.getDate()

  var age = now.getFullYear() - dobYear;
  var ageMonth = now.getMonth() - dobMonth;
  var ageDay = now.getDate() - dobDay;

  if (ageMonth < 0 || (ageMonth == 0 && ageDay < 0)){
    age = parseInt(age) - 1;
console.log(age);
  }
    if(age <18) {
        bfToggleFields('on','element','legalguardian',bfDeactivateField);
    }
   else if(age >= 18)  {
        bfToggleFields('off','element','legalguardian',bfDeactivateField);
    }

}
Please change that and let me know whether that resolves the issue.

If it doesn't I will send you a package with my form.

Regards,

Mihaela
#236297
The following user(s) said Thank You: multiweb
  • multiweb
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

multiweb replied the topic: Conditional Field If Less than 18 Years Old

Good eye!

That works perfectly, thank you very much for your help and perseverance!
#236301
  • Posts: 2359
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Conditional Field If Less than 18 Years Old

Thank you for your kind words.

I'm glad that I've helped and that this is now working for you. :)

Best regards,

Mihaela
#236303
Moderators: ForumSupporttomeperica
Time to create page: 0.070 seconds

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription 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 for just 49! (Summer Sale)

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

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