java script validate if person is over 18 year old RRS feed

  • Question

  • hi there,

    I want to validate a person 18 year old on the fieldchange event with a message .How can iacheive this


    Thursday, September 19, 2013 7:07 PM

All replies

  • Use the birthday of the person to calculate age. Add a if condition to check your condition and throw an alert.

    Refer to Guido's blog for Age calculation.

    Hope this helps!

    If my response helps you in finding your answer then please click 'Mark as Answer' and 'Vote as Helpful'

    Thursday, September 19, 2013 9:26 PM
  • I am thinking u can do with javascirpt. just you have take the value crom Birthday and check it, then popup the desire msg.

    function CalculateAge(birthday, ondate) { // if ondate is not specified consider today's date if (ondate == null) { ondate = new Date(); } // if the supplied date is before the birthday returns 0 if (ondate < birthday) { return 0; } var age = ondate.getFullYear() - birthday.getFullYear(); if (birthday.getMonth() > ondate.getMonth() || (birthday.getMonth() == ondate.getMonth() && birthday.getDate() > ondate.getDate())) { age--; } if(age>18)



    } }




    microsoft blog

    Friday, September 20, 2013 7:20 AM