Text / Text Area / Select-one / Select-multiple Field Validation:
Updated RCS Code for Form JS Validation Including Select-Multiple Type:
Thanks to Marc of
Rocking Chair Software:
http://www.rockingchairsoftware.com
Addition to RCS and MW code to retrieve the JavaScript Control RTF field contents:
if(CheckAllFields() == true) {
GetJSEditorData(); // used with the JS digi JavaScript Control RTF field
_getEditAppletData(); // used with java applet RTF field
//_doClick('$Refresh', this, null); // uncomment to do refresh instead of submit
f.submit();
}
Addition to RCS and MW code to confirm field exists is below. Add it just below the function start.
function CheckField(field, msg) {
if (field=== undefined) {
// field is missing, abort check
return true;
}
Addition to RCS and MW code that verifies existence of field before validation for the clear field and check field validation functions. Needed to catch if undefined so that JS doesn't blow up on a missing, misspelled, or expectably hidden by hide-when.
ClearFldStyleCheckFieldUpdated.rtf
Addition to RCS code that verifies a file upload control has something in its Browse field.
(It does not verify the text is legit if the user hand entered something.)
Additional function to check the value (and Text) of a drop-down selection for validation comparisons:
CheckFldVal.txt
Radio Button Field Validation:
MW Addition to RCS code to check a Radio Button group:
ButtonWhichOptionSelected.txt
MW Addition to set or check a radio button group:
SetButtonValue.rtf
Checkbox Field Validation:
MW Addition to RCS code to check a set of Checkboxes to make sure that at least one of the check boxes are checked.
Better version of checkbox_validation_function.txt that can also handle a single/lone checkbox:
checkbox_with_singlebox_validation.txt
MW Addition to RCS code to check if a specific checkbox (value) has been checked.
IsCheckBoxValueMatchedPassedValue.txt
MW Addition to RCS code to check if any list box item has been selected.
CheckListField.rtf
E-mail and Phone Number (dashed: 123-123-1234) Validation:
Validates that an e-mail has a format such as:
jane.doe@mydomain.com
jdoe@mydomain.com.au
Validates phone number for fixed dashed format of 111-222-3333.
EmailAddressPhoneNumber.txt
Number Field Validation:
Validates that a field contains ONLY numbers (e.g. Positive integer whole numbers).
CheckNumberField.txt
Validate Field Value Starts With a Matching String - @Begins Equivalent:
function CheckFldBegins(field, chkstr, msg) {
var curstr;
if (field.type=="text" | field.type=="textarea") {
curstr = field.value;
if ( curstr.startsWith( chkstr ) ) {
field.className="";
return true;
} else {
// failure
field.className="error";
errorMsgs += msg + "\n\r";
field.focus();
return false;
}
}
// not correct type, return true
field.className="";
return true;
}
previous page
|