Domino Code Fragment

Code Name*
JavaScript failContains function
Date*
04/19/2000
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.
Description*
The JavaScript failContains function looks like this:
Type*
JavaScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Return either a Boolean True or False value so that we can stop the submit. If the function is True, or if a validation failed, we stop the submit, return a JavaScript alert with a specific failure message, and focus the cursor on the field that failed the validation test. T he function illustrated above call three subroutines: getFieldValue, trimBlanks and alertBox. The getFieldValue function retrieves the
actual value the user entered or selected in the field being tested. To
further explore the getFieldValue function, we need to consider input
data types and browser types.
Files/Graphics attachments (if applicable): Code:
Here is the syntax for the failContains logic:

if (parent.failContains( form.EditProfileFormKeyOverride_1, "N", "You
must select Yes to continue.", "radio") ) return;


if (parent.failContains( form.EditProfileFormKeyLabel_4,
',;:',"Labels/questions cannot contain commas, colons, or
semicolons.", "text", "mult")) return;


              The JavaScript failContains function looks like this:

function failContains( vField, vValue, vMessage, vType ) {

//this function will stop the submit if a field contains a specified value
(or value list)


//get the field value...
theValue = getFieldValue (vField, vType);


//check argument list to see if we are testing multiple characters...
var count = ( failContains.arguments.length == 6 ) ? vValue.length-1 :
0;
var value = ( failContains.arguments.length == 6 ) ?
vValue.substring(0,1) : vValue;


//fail the submit if the field contains the value(s)...
for ( i = 0; i <= count; i++) {
if ( theValue.indexOf(value) > -1) {


alertBox ( vField, vMessage, vType );

return (true);

}
value = ( count > 0 ) ? vValue.substring(i+1,i+2) : vValue;
}


//otherwise continue...
return (false)
}