Hi
I'm using a datepicker where users have to select their birth date, after that their age is calculated with some javascript code i found on this forum.
When I run the form in preview mode the code runs without error but on the front end nothing happens. I suppose this has something to do with the version of jquery but i cannot seem to figure out how to solve this.
If I inspect the page in chrome i get the following error:
the code (part of) I used you can find below.
Does anybody have a solution for this?
Thanks for your help!
I'm using a datepicker where users have to select their birth date, after that their age is calculated with some javascript code i found on this forum.
When I run the form in preview mode the code runs without error but on the front end nothing happens. I suppose this has something to do with the version of jquery but i cannot seem to figure out how to solve this.
If I inspect the page in chrome i get the following error:
(index):307 Uncaught TypeError: jQ(...).datepicker is not a function at HTMLDocument.<anonymous> ((index):307) at i (jquery.js?ver=1.12.4:2) at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2) at Function.ready (jquery.js?ver=1.12.4:2) at HTMLDocument.K (jquery.js?ver=1.12.4:2)
the code (part of) I used you can find below.
jQuery(document).ready(function(jQ) { var age, Geboortedatum; jQ("#Geboortedatum").datepicker({ onClose: function() { Geboortedatum = jQ("#Geboortedatum").val(); age = getAge(Geboortedatum); jQ("#Leeftijd").val(age); function getAge(dateString) { var birthDate = new Date(dateString); var age = seizoen - birthDate.getFullYear(); var m = 8 - birthDate.getMonth(); if (m < 0 || (m === 0 && 24 < birthDate.getDate())) { age--; } return age; }; } }); });
Does anybody have a solution for this?
Thanks for your help!