Domino Code Fragment

Code Name*
JavaScript function for failNull
Date*
04/19/2000
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.
Description*
The JavaScript function for failNull follows:
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. The 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 failNull syntax:

if(parent.failNull(form.ProfileApprovers1,"You must specify one or
more approvers for the first approval step","text")) return;


             The JavaScript function for failNull follows:   

function failNull ( vField, vMessage, vType) {

//this function will stop the submit if a field is null or contains all spaces

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


//if the field value is null, we fail and return true...
if ( theValue == "" ) {


alertBox ( vField, vMessage, vType );

return ( true );

}

//remove any spaces from the value

trimField = trimBlanks( theValue );

//if the field value is all spaces, fail and return true...
if ( trimField =="" ) {


alertBox ( vField, vMessage, vType );

return ( true );

}

//otherwise continue...

return ( false );

}