Coding with Velo API

I want my users to choose their age before register. If the age is under 18( want the return to be ‘False’ ) Else (‘true’).
So, the problem is how to run this code to automatically detect that user input age is under 18. I search Velo APIs and database properties, can’t find anything. Only property closed, is the date of the creation or update which is available in my data collection properties. Any help?

You may want to use → “Custom-Fields” during registration process…

I am using custom field. The problem is how to run this code to automatically detect that user input age is under 18. I search Velo APIs and database properties, can’t find anything.
Any example ?

This is my Code but not running. Always returning console in after “else”

I find a way to do run my code and it now running perfectly. After registration button show, I can now call the API “Authentication” to_Register the user. Thank you All.

                                                            **let**  date  =  $w ( "#datePicker1" ). value ; 

                                                            **var**  todaysDate  =  **new**  Date (). getFullYear ();  //Current year 
                                                            **let**  inputDate  =  $w ( "#datePicker1" ). value ;  //Value from date picker 

                                                            **var**  inputDateYear  =  inputDate . getFullYear (); 

                                                            $w ( "#alerterms1" ). text  =  'Your age is:'  +  String ( todaysDate  -  Number ( inputDateYear )) +  'years' 

                                                            **let**  age  =  String ( todaysDate  -  Number ( inputDateYear )) 
                                                            console . log ( age ) 
                                                            **let**  minimum  =  1000  *  18  *  365  *  60  *  60  *  24 
                                                            **if**  (( todaysDate  -  Number ( inputDateYear )) >  18 ) { 
                                                                $w ( "#registrationButton" ). show (); 
                                                                console . log ( 'User have the minimum age' ) 
                                                                $w ( "#loading" ). show (); 

                                                            }  **else**  { 
                                                                // WHY I GET THIS RESULT ANYWAY ?????????? 
                                                                console . log ( 'User does not have the minimum age' ) 
                                                                $w ( "#alerterms1" ). text  =  ' You have to be 18 years old to use proceed' 
                                                            }

Calculation of dates and times should be done by using → “timestamps”

You even get an error here…


Because such a calculation is not doable.

Break everything down to timestamps…

$w('#datePicker1').onChange(()=>{
    let today = new Date();
    let todayTimeStamp = (new Date(today)).getTime(); 
    console.log("Timestamp-Today: ", todayTimeStamp);
    let date = $w('#datePicker1').value;     
    console.log("Date: ", date);
    let userTimeStamp = (new Date(date)).getTime(); 
    console.log("Timestamp by User: ", userTimeStamp);
    let resultingTimestamp = userTimeStamp-todayTimeStamp; 
    console.log("ResTimestamp: ", resultingTimestamp);
});

And then convert back from timestamp to date and time.

This way you will be able to calculate Dates & Time.

Thank you very much ! Grateful !