1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV06246514"><META NAME="lcid" CONTENT="1033"><title>Custom validation in the Data Validation developer sample form</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><p id="ExpandAllLine" class="ExpFav"><a href="#" onclick="ExpandAll()" onkeypress="ExpandAll()" class="DropDown"><img id="picHeader" border="0" src="expandtri.gif" alt="Show All"><span id="ExpandAll">Show All</span></a></p><h1>Custom validation in the Data Validation developer sample form</h1><div class="ofvbanav"><span class="ofvbanavreuse" id="seealso" onclick="toggleList()" onkeypress="toggleList()"></span><span class="ofvbanavreuse" id="specifics" onclick="toggleList()" onkeypress="toggleList()"></span></div><p>Custom (or declarative) validation in Microsoft Office InfoPath 2003
is used to check for required fields,
verify
a range of values, and ensure the accuracy of a field. You can use the <b class="ui">Data Validation</b> dialog box to create complex validation constraints that perform calculations and validate the data in other fields. Validation errors can be displayed as <a href="#" class="glossary" onclick="AppendPopup(this,'xdinlinealert')" onkeypress="AppendPopup(this,'xdinlinealert')">inline alerts</a> or <a href="#" class="glossary" onclick="AppendPopup(this,'xddialogboxalert')" onkeypress="AppendPopup(this,'xddialogboxalert')">dialog box alerts</a>. In either case, you can write error messages that tell the user how to fix the invalid entry. As with schema-based validation, custom validation constraints are attached to fields in the form, and the validation is invoked when a user changes the data in a field.</p><p><b>Note</b> The <b class="ui">Data Validation</b> dialog box is available via the <b class="ui">Properties</b> dialog box for each of the Office InfoPath 2003 controls.</p><p>When you create a custom data validation constraint in the <b class="ui">Data Validation</b> dialog box, Office InfoPath 2003 creates an <b class="bterm"><a href="xsfelmerrorCondition.htm" id="HV01021473" lcid=" ">errorCondition</a></b> element within the <b class="bterm"><a href="xsfelmcustomValidation.htm" id="HV01021463" lcid=" ">customValidation</a></b> section of the <a href="#" class="glossary" onclick="AppendPopup(this,'xdformdefinitionfilexsf')" onkeypress="AppendPopup(this,'xdformdefinitionfilexsf')">form definition (.xsf) file</a>. The following is an example of the validation constraints created in the .xsf file for the cost field in the Data Validation developer sample form:</p><pre><code><xsf:customValidation>
<xsf:errorCondition
match="/sampleData/travelExpenses/expense/cost"
expressionContext="."
expression=". &lt; 0 or . &gt; 500">
<xsf:errorMessage
type="modeless"
shortMessage="The cost of the item must be more than
$0.00 and cannot go over $500.00.">The cost of the
item must be more than $0.00 and cannot go over $500.00.
</xsf:errorMessage>
</xsf:errorCondition>
</xsf:customValidation>
</code></pre><p>The <b class="bterm"><a href="xsfatrmatch_3.htm" id="HV01021565" lcid=" ">match</a></b> attribute of the <b class="bterm">errorCondition</b> element specifies the <a href="#" class="glossary" onclick="AppendPopup(this,'xdxpath')" onkeypress="AppendPopup(this,'xdxpath')">XPath</a> expression that is used to bind the custom data validation constraint to the field, and the <b class="bterm"><a href="xsfatrexpression.htm" id="HV01021545" lcid=" ">expression</a></b> attribute is used to specify the constraint.
</p><p> The <b class="bterm"><a href="xsfelmerrorMessage.htm" id="HV01021474" lcid=" ">errorMessage</a></b> element is nested within the <b class="bterm">errorCondition</b> element and is used to specify the error message that appears when the value of the associated field violates the constraint. The <b class="bterm"><a href="xsfatrshortMessage.htm" id="HV01021601" lcid=" ">shortMessage</a></b> attribute equates to the <b class="ui">ScreenTip</b> field in the <b class="ui">Data Validation</b> dialog box, and the value of the <b class="bterm">errorMessage</b> element equates to the <b class="ui">Message</b> field in the <b class="ui">Data Validation</b> dialog box. The <b class="bterm"><a href="xsfatrtype_1.htm" id="HV01021616" lcid=" ">type</a></b> attribute is used to specify error type.</p><script type="text/javascript" language="JScript" src="ofvbanl.js"></script><span id="ofVBAISpan" class="ofvbaispan"><iframe id="ofVBAIFrame" frameborder="0" marginheight="0" marginwidth="4" scrolling="auto" width="100%" src="../links/inconCustomValInDVForm_l.htm"></iframe></span><center><a href="XMLSchemaCopyright_HV01147162.htm">©2003-2004 Microsoft Corporation. All rights reserved.</a>
Permission to copy, display and distribute this document is available at: <a
href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&CTT=11&Origin=HV011232471033"
target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>
|