Home Server
New Blog Posts: Merging Reports - Part 1 and Part 2

Javascript ISAPI web tier demo problem with dates

edited February 2004 in Server
Hi!

I have discussed about search dialog problem in IE (using Web tier ISAPI
demo). I got your "rsWebJavaScriptSearchValidation.pas" file and have
modified IsDate checking of date values (I use "dd.mm.yyyy" format). I saw
that "Date.parse" is not Ok in all situations and on that subject there are
many articles. So my modified function looks like:
function IsDate(aValue)
lsBody := '';
lsBody := lsBody + 'function IsDate(aValue)' + #13#10;
lsBody := lsBody + '{' + #13#10;
//mine
lsBody := lsBody + ' var re=
/^(3[01]|0[1-9]|[12]\d)\.(0[1-9]|1[012])\.\d{4}/;' + #13#10;
lsBody := lsBody + ' var lbPassed = (re.test(aValue) == true);' + #13#10;
//org
// lsBody := lsBody + ' var lbPassed = !isNaN(Date.parse(aValue));' +
#13#10;
// lsBody := lsBody + ' lbPassed = lbPassed && (aValue.indexOf(":")
== -1);' + #13#10;

lsBody := lsBody + ' lbPassed = lbPassed || (aValue == "");' + #13#10;
lsBody := lsBody + ' lsResult = "";' + #13#10;
lsBody := lsBody + ' if (!lbPassed)' + #13#10;
lsBody := lsBody + ' lsResult = aValue + " ' + ppLoadStr(56) + '";' +
#13#10; // 'is not a valid date.'
lsBody := lsBody + ' return lsResult;' + #13#10;
lsBody := lsBody + '}' + #13#10;

aFunctionList.AddFunctionIfNew('IsDate', lsBody);

Result := 'IsDate';

end;

Problem still persist in a way that search values (date) are not recognized
properly (they are checked correctly but latter not recognized in a good
way). Eventhought after new search (when report is shown with some or none
data), old search values are totally mad (31.12.1899 or something like that,
buit never understand corectly ... same to input values before).
What to do to make that work...

Regards,

Benjamin

Comments

  • edited February 2004

    There is a second piece of JavaScript that converts the date entered by the
    user into a standard format (CCYY-MM-DD) that will be processed by the
    WebTier. I will send this unit to you.


    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2004
    Hi!
    But I've wonder could that be made as public property with some common date
    formats...

    Hope that with date time there will not be problems like that ....

    THX!
    Benjamin

  • edited February 2004

    The intent of the architectuire is that the Javascript can be designed to
    validate the user input and then convert the user input to a standard format
    that is sent to the WebTier. The challenge is how to structure the
    Javascript validation to allow a variety of formats.



    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2004
    First of all....all users shoud use the same date format.

    Format checking is simple...Provide checking of regular expressions. Here is
    example for dd.mm.yyyy format:

    lsBody := lsBody + ' var re=
    /^(3[01]|0[1-9]|[12]\d)\.(0[1-9]|1[012])\.\d{4}/;' + #13#10;

    it is very easy to make other know combinations and to put in script
    accordding some propertie.

    for format dd/mm/yyyy, checking would be like:

    lsBody := lsBody + ' var re=
    /^(3[01]|0[1-9]|[12]\d)\/(0[1-9]|1[012])\/\d{4}/;' + #13#10;

    Looks simple or I do not understand the problem.
    Regrads,
    Damir

  • edited February 2004

    Sorry I think I misunderstood. You are requesting that a new property be
    added to the WebTier to enable the developer to specify an allowable date
    format. I can add this to our todo list for future enhancements. Thanks for
    the suggestion....

    For now, you will need to modify the Validation and Marshalling JavaScript
    that I sent to you.

    It would be nice if the JavaScript Date class handled this in a more
    flexible manner - validating dates based upon the user locale.


    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.