Question

reg age must be equal or more than 18

Hi team



this the code is done by using java script .



Age must be equal or more than if we select less than 18 it will show an alert



how to do this code using require js.



Hoping for positive reply.





function calculateAge() {

var seldate = document.getElementById("childrenAge").value;

dt1 = new Date(); //today date

dt2 = new Date(seldate); //selected date

var age =diff_years(dt1, dt2);

if(age<18){

alert("please select date more than or equals to 18");

document.getElementById("childrenAge").value =""

}

}



function diff_years(dt1, dt2)

{



 var diff =(dt2.getTime() - dt1.getTime()) / 1000;

  diff /= (60 * 60 * 24);

 return Math.abs(Math.round(diff/365.25));



}

Like 0

Like

1 comments

Hello.

The very similar example of the implementation can be found on the academy:

https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-field-…

You only need to adjust the first example a little bit so it suits your needs.

Best regards,

Matt

Show all comments