Summary

This article covers an example of a 200 character limit script.

Table of Contents


Description

This script counts the number of characters in a target field and determines whether or not it is less or equal to two hundred. If the value is greater than 200 an alert fires.

Note: If no alert is needed, utilize the Max Length column on the ‘Question Types – Definition’ tab in the dataArchitect file. This will hard stop text characters at the designated number. A simple edit check can be added instead, which will fire an alert. The edit check expression would be as follows: questions.size <= 200


Script

<script scriptId="characterLimit200">
    <body>
        <s:alert>
            <s:expression>
                <s:lte>
                    <s:length>
                        <s:value>
                            <s:stringPath path=":value"/>
                        </s:value>
                    </s:length>
                    <s:number value="200"/>
                </s:lte>
            </s:expression>
            <s:correction>
                <s:string value="required"/>
            </s:correction>
            <s:text>
                <s:string value="This field cannot be greater than 200 characters in
                 length. Please verify."/>
            </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' />
</script>



Need more help?

Please visit the Fountayn Contact Information page.