How do you subtract the year from the current year

I am trying to force the user to enter their age but not less than 17 from the current year.

Capture

In the data formatter when you select your value choose Date —> Add Years and set value to -17

Hello,

I tried it. I receive this error.

Capture1 Capture

You might needed to also use the formatter to convert to date. I’m not at my computer at the moment so can’t provide screenshots.

You might also check this post …

I checked it. I think i understood a little bit but I just don’t even want to bother giving them access to the database and put it their birthday is not meeting the requirement of the site.

This is going to need more than just a min of the value, it first needs to know the current date.

  1. Add a Data > Date and Time component first
  2. Select your Number Input and add a Dynamic Attribute
    You want the year from the date and time component then the addYears -17, then the get Year so your bindings formatter will look like
    Screenshot 2020-06-02 at 11.01.38
    All this will do is set the min parameter of the number field to 2003.

The code should look like

<dmx-datetime id="var1"></dmx-datetime>
<input id="text1" name="text1" type="number" class="form-control" dmx-bind:min="var1.datetime.addYears(-17).getYear(var1.datetime)" required="">
1 Like

Thank you for your help. :+1:

It is working perfectly.