web date field validation for hcl domino - isnotesdate() javascript function


HCL Notes and Domino: Tips & Tricks

Web Date Field Validation for HCL Domino - IsNotesDate() JavaScript function
Sept 24, 2012 (updated Nov 3, 2021)


By Lance Zakin, HCL CASA, CAAD
Notes and Domino
NotesMail - HCL BP
The code below can be used for any application and supports international date formats. The function is called using 5 parameters as described in the code comments. The code supports the same valid time data type functionality as a HCL Notes client including date format styles "MDY, DMY, YMD", and date format separators "back slash, dash, period" which depends on the server date setting.

i.e. Valid formats for September 1, 2020 using MDY format style and back slash format separator: 9/1/2020, 09/20 09/01/2020, 9/1/20, 09/01/20, etc.

The code can be copy/pasted into the JS Header object, but be sure not to run the submit button code if validation fails. Feel free to use the code, but please do not remove the comment which denotes HCL Business Partner "IVE Technologies LLC (dba NotesMail)" as the developer.

HCL BP NotesMail sells a Domino web developer tool called "Web Date Picker for HCL Notes and Domino". It includes the IsNotesDate() JavaScript function for international date validation, as well as, an optional web date picker interface (graphical display calendar control pop-up). Web Date Picker allows a Domino developer to add a web date picker to automatically populate a field on a web form: https://www.notesmail.com/WebDatePicker

NOTE: Domino 12 and lower does not natively support a web date picker: Domino calendar features that are not supported on the Web

YouTube video (start video at 16:45 minutes): Implement a web date picker with international date validation in a Domino web app

JavaScript code: Validation example
function validation() {
txtDate = document.forms[0].datDate.value;
txtDateLen = document.forms[0].datDate.value.length;
DateErrorMsg1 = "Date is a required field.\n\nPlease click the calendar icon to select a date.";
if (txtDate == "" || txtDateLen == 1) { alert(DateErrorMsg1); return; }
DateErrorMsg2 = "Field Contains Incorrect Value\n\nUnable to interpret Time or Date";
//
// Web Date Picker for HCL Notes and Domino integration code
// ©1997-2021 IVE Technologies LLC (dba NotesMail) - www.notesmail.com/Crucial-Notes-tools
//
// INTERNATIONAL WEB DATE FIELD VALIDATION
//
// PARAMETERS
// txt_date: Date (text data type) i.e. 01/01/2013
// num_style: Date Format Style (num data type) i.e. 1 = MDY, 2 = DMY, 3 = YMD
// num_sep: Date Format Separator (num data type) i.e. 1 = back slash, 2 = dash, 3 = period
// num_span: Date Span (num data type) i.e. 1 = ignore, 2 = less equal today, 3 = greater equal today
// num_date: Date Compare (num data type) i.e. 1 = ignore, 2 = return date data type value
//
if (!IsNotesDate(txtDate,1,1,1,1)) { alert(DateErrorMsg2); return; }
document.forms[0].button.value="Processing...";
document.forms[0].submit();
}

JavaScript code: IsNotesDate() function
function IsNotesDate(txt_date, num_style, num_sep, num_span, num_date) {
//
// Web Date Picker for HCL Notes and Domino integration code
// ©1997-2021 IVE Technologies LLC (dba NotesMail) - www.notesmail.com/Crucial-Notes-tools
//
// INTERNATIONAL WEB DATE FIELD VALIDATION
//
// PARAMETERS
// txt_date: Date (text data type) i.e. 01/01/2013
// num_style: Date Format Style (num data type) i.e. 1 = MDY, 2 = DMY, 3 = YMD
// num_sep: Date Format Separator (num data type) i.e. 1 = back slash, 2 = dash, 3 = period
// num_span: Date Span (num data type) i.e. 1 = ignore, 2 = less equal today, 3 = greater equal today
// num_date: Date Compare (num data type) i.e. 1 = ignore, 2 = return date data type value
//
[The full code has been removed since it is now maintained by HCL BP NotesMail in a product called Web Date Picker: https://www.notesmail.com/WebDatePicker]

.