<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
		<id>https://www.bxpsoftware.com/wixi/index.php?action=history&amp;feed=atom&amp;title=JavaScript_-_Extending_Outcome_Validation</id>
		<title>JavaScript - Extending Outcome Validation - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.bxpsoftware.com/wixi/index.php?action=history&amp;feed=atom&amp;title=JavaScript_-_Extending_Outcome_Validation"/>
		<link rel="alternate" type="text/html" href="https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;action=history"/>
		<updated>2026-10-23T18:43:57Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.28.2</generator>

	<entry>
		<id>https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=2230&amp;oldid=prev</id>
		<title>Philip Lacey at 19:25, 9 November 2014</title>
		<link rel="alternate" type="text/html" href="https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=2230&amp;oldid=prev"/>
				<updated>2014-11-09T19:25:07Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en-GB'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 19:25, 9 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l130&quot; &gt;Line 130:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 130:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Module Specific:Form Management]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Topic:JavaScript]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Philip Lacey</name></author>	</entry>

	<entry>
		<id>https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=1882&amp;oldid=prev</id>
		<title>Philip Lacey: Philip Lacey moved page Extending Outcome Validation to JavaScript - Extending Outcome Validation without leaving a redirect</title>
		<link rel="alternate" type="text/html" href="https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=1882&amp;oldid=prev"/>
				<updated>2014-09-01T14:06:03Z</updated>
		
		<summary type="html">&lt;p&gt;Philip Lacey moved page &lt;a href=&quot;/wixi/index.php?title=Extending_Outcome_Validation&amp;amp;action=view&quot; class=&quot;new&quot; title=&quot;Extending Outcome Validation (page does not exist)&quot; data-bs-title=&quot;Extending Outcome Validation&quot; data-bs-is-contentpage=&quot;1&quot;&gt;Extending Outcome Validation&lt;/a&gt; to &lt;a href=&quot;/wixi/index.php/JavaScript_-_Extending_Outcome_Validation&quot; title=&quot;JavaScript - Extending Outcome Validation&quot; data-bs-title=&quot;JavaScript - Extending Outcome Validation&quot; data-bs-is-contentpage=&quot;1&quot;&gt;JavaScript - Extending Outcome Validation&lt;/a&gt; without leaving a redirect&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style='vertical-align: top;' lang='en-GB'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 14:06, 1 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en-GB'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Philip Lacey</name></author>	</entry>

	<entry>
		<id>https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=1881&amp;oldid=prev</id>
		<title>Philip Lacey at 14:03, 1 September 2014</title>
		<link rel="alternate" type="text/html" href="https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=1881&amp;oldid=prev"/>
				<updated>2014-09-01T14:03:57Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en-GB'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 14:03, 1 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l119&quot; &gt;Line 119:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 119:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now with that in place, we can put into each &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;function&lt;/del&gt;....&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now with that in place, we can put into each &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;outcome&lt;/ins&gt;....&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Philip Lacey</name></author>	</entry>

	<entry>
		<id>https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=1880&amp;oldid=prev</id>
		<title>Philip Lacey: Created page with &quot;== Overview ==   Extending the validation of outcomes on the page involves you using custom JavaScript and knowing a little about how the validation engine works.   The primar...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.bxpsoftware.com/wixi/index.php?title=JavaScript_-_Extending_Outcome_Validation&amp;diff=1880&amp;oldid=prev"/>
				<updated>2014-09-01T14:03:07Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Overview ==   Extending the validation of outcomes on the page involves you using custom JavaScript and knowing a little about how the validation engine works.   The primar...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extending the validation of outcomes on the page involves you using custom JavaScript and knowing a little about how the validation engine works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary validation of the page is done in a function called &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
function js_fn_Master_Validation_Script(obj) {&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This function uses two variables called blError and strError_Message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If blError == true then the page will not submit.  The message that the user sees is in the strError_Message variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function is called when the Submit button on the page is pressed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each outcome gets its own discrete set of rules &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
if (obj.value == 'Save Test') {&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Validation can be done using the standard outcome validation constructors.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Main Menu &amp;gt; Form Management &amp;gt; Form - Outcome Manager &amp;gt; Outcome - Edit &amp;gt; Choose your Form &amp;gt; Choose the outcome &amp;gt; JavaScript &amp;gt; Validation'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However further customisation can be done through &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Main Menu &amp;gt; Form Management &amp;gt; Form - Outcome Manager &amp;gt; Outcome - Edit &amp;gt; Choose your Form &amp;gt; Choose the outcome &amp;gt; JavaScript &amp;gt; JavaScript'''  This section injects custom JavaScript into this js_fn_Master_Validation_Script function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Worked Example ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you wanted to add validation to an outcome to check if text was in a box.  Firstly work out the Form specific name of the field we want to validate. e.g. strCDA_X_field_0_1.   If you click the pencil icon to the right of the question, at the very top of the editing page, you will see the name there.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So if we want to check the content has some values then...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Firstly we work out how long is the data that has been typed into the box&lt;br /&gt;
var intLength_CDA_X_field_0_1 = document.getElementById('strCDA_X_field_0_1').value.length;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// If the length of the content is 0, then nothing has been typed in.&lt;br /&gt;
if (intLength_CDA_X_field_0_1 == 0) {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  // Firstly we tell bxp that we have found a validation error.&lt;br /&gt;
  blError = 'True';&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  // Along with any other validation messages, we tell the user how to correct the issue.&lt;br /&gt;
  // Please make your error messages helpful to your users so they know how to fix the issue&lt;br /&gt;
  strError_Message = strError_Message + 'Please type something into the strCDA_X_field_0_1 field.';&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From here you can add as many rules as you like to the outcome with as much custom validation as you require.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Function injection ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Putting in lots and lots of validation in an outcome can make the code difficult to manage over time.  Especially if the validation repeats.  e.g. 4 outcomes with the same validation.  If there is an update there are four validation routines to use rather than 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When this occurs it can be useful to &amp;quot;abstract&amp;quot; the validation to a centralised function.  Put your validation function into the onLoad of the Form.  Then all outcomes can access it.  So we in two steps.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 1 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Firstly we create a centralised validation function that returns text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function fn_CentralValidation() {&lt;br /&gt;
&lt;br /&gt;
  var strMyErrorMessage = '';&lt;br /&gt;
  var intLength_CDA_X_field_0_1 = document.getElementById('strCDA_X_field_0_1').value.length;&lt;br /&gt;
&lt;br /&gt;
  if (intLength_CDA_X_field_0_1 == 0) {&lt;br /&gt;
    strMyErrorMessage  = strMyErrorMessage  + 'Please type something into the strCDA_X_field_0_1 field.';&lt;br /&gt;
  }&lt;br /&gt;
  return strMyErrorMessage ;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Step 2 ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now with that in place, we can put into each function....&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var strMessage = fn_CentralValidation();&lt;br /&gt;
if (strMessage.length &amp;gt; 0){&lt;br /&gt;
  blError = 'True';&lt;br /&gt;
  strError_Message = strError_Message + strMessage;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Philip Lacey</name></author>	</entry>

	</feed>