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 Jun 6, 2024)


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, 2024 using MDY format style and back slash format separator: 9/1/2024, 09/01, 09/01/2024, 9/1/24, 09/01/24, 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.

NotesMail, a HCL Business Partner, 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 14 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-2024 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/2025
// 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-2024 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/2025
// 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 NotesMail, a HCL Business Partner, in a product called Web Date Picker: https://www.notesmail.com/WebDatePicker]

.