Quantcast
Channel: Adobe Community : All Content - LiveCycle Designer
Viewing all articles
Browse latest Browse all 5571

How can I force users to enter specifc format?

$
0
0

I'm using Livecycle Designer ES2 provided with Acrobat X Pro. 

 

I have a form where the age field is calculated from the date of birth field.  The date of birth field (DOB) is a date/time field.  The age field (Age) is a numeric field.

 

Problem is: when user enters 01/01/01 shows age as 101.  When user enters 01/01/2001 age shows 1.  All patterns are set to mm/dd/yyyy.  Is there a way to prohibit the user from continuing to the next field until the proper format is entered?  I'm open to any ideas which will acheive the desrired outcome.  I'm new to livecycle and javascript.  I suspect an easy solution but I can't seem to find it when searching the forums or LD help menu.

 

I've attached the script for the Age field in case it helps.

 

Age::calculate - (JavaScript, client)

 

var ageInYears = 0;

    var birthDate = new Date();

 

    if ( DOB.rawValue != null )

        {

        // Get current date, and convert user-entered date to a Date object.

        var curDate = new Date();

        birthDate.setTime(Date.parse(DOB.editValue));

       

        // Set initial age, current year - birth year

        ageInYears = curDate.getFullYear() - birthDate.getFullYear();

       

        // If we haven't reached the birth month yet, not yet 1 year older...

        if ( curDate.getMonth() < birthDate.getMonth() )

            ageInYears--;

        // If this month is same as birth month but we haven't reached the

        // birth date yet, not yet 1 year older...

        if ( curDate.getMonth() == birthDate.getMonth() )

            if ( curDate.getDate() < birthDate.getDate() )

                ageInYears--;

       

        // Set age in result field.

        this.rawValue = ageInYears;

            }


Viewing all articles
Browse latest Browse all 5571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>