Summary

This script converts the date of birth question to a partial date in order to do a comparison against the target partial dates. It also lists the date of birth question as a dependent path so that the script will re-evaluate if the date of birth is modified. The alert fires if the target dates are before the date of birth. Listing dependent question paths allow the script to trigger when a dependent variable existing on another form is updated with a new value. 


Script

<script scriptId="prior_dobCk">
    <body>
        <s:alert>
            <s:expression>
                <s:or>
                    <s:not>
                        <s:isSet/>
                    </s:not>
                    <s:not>
                        <s:isSet>
                            <s:question>
                                <s:question path="/screening/dm.dob"/>
                            </s:question>
                        </s:isSet>
                    </s:not>
                    <s:gte>
                        <s:partialDatePath path=":value"/>
                        <s:toPartialDate>
                            <s:datePath path="/screening/dm.dob:value"/>
                            <s:string value="dd[]/MMM[]/yyyy[]"/>
                        </s:toPartialDate>
                    </s:gte>
                </s:or>
            </s:expression>
            <s:correction>
                <s:string value="optional"/>
            </s:correction>
            <s:text>
                <s:string value="This date is before the date of birth.  Please clarify."/>
            </s:text>
        </s:alert>
    </body>
    <target typeId="questions" when="preprocess" shouldReconcile="true"/>
    <target typeId="go" when="preprocess" shouldReconcile="true"/>
    <target typeId="here" when="preprocess" shouldReconcile="true"/>
    <dependent path="/screening/dm.dob"/>
</script>



Need more help?

Please visit the Fountayn Contact Information page.