web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Date of Birth Validation

(0) ShareShare
ReportReport
Posted on by

Hi Guys,

I have a Age Field & D.O.B Field.Already am write a javascript for Calculating Age.But Now I Want to Validate date of Birth Field How to Validate the Field Using JavaScript.

Thank You

*This post is locked for comments

I have the same question (0)
  • Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    What do you want to validate?

    Do you want to validate to make sure that the date is in a particular range?

  • DineshRaja Profile Picture
    on at

    D.O.B should accept the date since the current date

  • Suggested answer
    Community Member Profile Picture
    on at

    Compare it with the current date. Something like

    dob < new Date()

  • Suggested answer
    Community Member Profile Picture
    on at
  • DineshRaja Profile Picture
    on at

    its not working..

  • Gopalan Bhuvanesh Profile Picture
    11,401 on at

    HI

    Please copy the full code here

  • DineshRaja Profile Picture
    on at

    var BirthDate = Xrm.Page.getAttribute("tkcg_dob").getValue();

      var Today = new Date();

      if (BirthDate > Today) {

          alert('Date of birth can not be greater than the date today');

          Xrm.Page.getAttribute("tkcg_dob").setValue(); //set null value

      }

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    What is the Behavior and Format of the date field tkcg_dob?

    You can also check the value of DOB when you enter a date value in that field when debugging.

    Today has the time component, so when both dates are equal it will not work properly as compare compares both date and time.

    Or you can change the code

    if(BirthDate < Today)

    {

    //do something

    }

    else

    {

    alert('Date of birth can not be greater than the date today');

          Xrm.Page.getAttribute("tkcg_dob").setValue(null); //set null value

    }

  • Samrando Profile Picture
    270 on at

    try to write last  line of code like below

         Xrm.Page.getAttribute("tkcg_dob").setValue()=null; //set null value

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    If you have issue only with clearing the date field, you can use as below:

          Xrm.Page.getAttribute("tkcg_dob").setValue(null); //set null value

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans