logo

Response

« Return to the main article

You are viewing this page out of context. To see it in the context it is intended please click here.

About This Page

Reply posted by David Marsh on Sun 26 Nov 2000 in response to JavaScript Form Validator, Version 1.8

Some minor enhancement suggestions!

A couple of things to keep in mind when using the JavaScript validator.


The first is to do with two digit and four digit years being returned by Domino.


When using the @Adjust formula or Now() in LotusScript, if the regional
settings on the servers OS that Domino is running indicate a short date style
like this dd/MM/yy then obviously you get two digits for the year. It is
recommended to change the settings to dd/MM/yyyy and restart the domino server.


Something for developers to keep in mind.


A small change to the validator script to simplify the use of javascript arrays
and regular expressions is to make the following change to the DateComponents
function in the global.js page.


function DateComponents(dateStr, format) {


var results = new Array();


REPLACE THESE TWO LINES
--------------------------------------------------------
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = dateStr.match(datePat);
--------------------------------------------------------
WITH THIS ONE
--------------------------------------------
var matchArray = dateStr.split( /\/|-/ )
--------------------------------------------


if (matchArray == null) {
return null;
}


// parse date into variables
if (format.charAt(0)=="d"){ //what format does the server use for dates?
results[0] = matchArray[1];
results[1] = matchArray[3];
} else {
results[1] = matchArray[1];
results[0] = matchArray[3]; }
results[2] = matchArray[4];
return results;
}