Print

Print


Thank you for the input, I'm sure it will be helpful.
Carolyn



>________________________________
>From: SUBSCRIBE LIS-PUB-LIBS Anonymous <[log in to unmask]>
>To: [log in to unmask]; Carolyn Carter <[log in to unmask]> 
>Sent: Friday, 15 February 2013, 9:55
>Subject: Re: Do some services bring it on themselves..?
>
>Interesting post.  I use Libraries West and haven't come across this (obviously haven't used that form though).  Having a look at the page it uses JavaScript to validate the date (I've copied in the function at the bottom of this message for any geeks like me)  The page is here:http://www.libswest-wisdom-sw.net/cgi-bin/crxadmin/proformasep.php
>
>Now, all seems OK at first look.  What the function does it takes the input parameters by separating up what has been typed in the date field using the backslashed (dd/mm/yyy), and then converting those into a date value that the system recognises.  It confirms this system date is valid by then working backwards and testing that the day, month and year are the same as the ones that were originally entered (certainly a long way round of validating a date).  This is done in this bit:
>if ((year == test.getYear()) &&amp; (month-1 == test.getMonth()) &&amp; (date == test.getDate())) {
>
>But funnily enough it will never pass this test because getYear() no longer returns a year in the format YYYY, it returns the year minus 1900 (don't ask me why).  So if you enter 01/03/2013 it will correctly convert that into a date using 01, 03, and 2013, then check that 2013 is equal to 113, which it isn't!  So the page will never work. It used to work but that getYear function has been deprecated and the developers should change it to getFullYear(), which will fix everything.
>
>So a simple solution!  Hope they fix it soon, two years is definitely too long.
>
>
>function isValidDate(myDate,sep) {
>// checks if date passed is in valid dd/mm/yyyy format
>
>if (myDate.length == 0) {
>        return true;
>    }
>
>if (myDate.length == 10) {
>
>if (myDate.substring(2,3) == sep &&amp; myDate.substring(5,6) == sep) {
>            var date  = myDate.substring(0,2);
>            var month = myDate.substring(3,5);
>            var year  = myDate.substring(6,10);
>
>            var test = new Date(year,month-1,date);
>            var now = new Date();
>
>            if ((year == test.getYear()) &&amp; (month-1 == test.getMonth()) &&amp; (date == test.getDate())) {
>        if( test.getYear() < now.getYear() ) {
>                    reason = 'Date entered must be after today';
>                    return false;
>        }
>        if( test.getYear() > now.getYear() ) {
>                    reason = '';
>                    return true;
>        }
>        if( test.getMonth() < now.getMonth() ) {
>                    reason = 'Date entered must be after today';
>                    return false;
>        }
>        if( test.getMonth() > now.getMonth() ) {
>                    reason = '';
>                    return true;
>        }
>        if( test.getDate() <= now.getDate() ) {
>                    reason = 'Date entered must be after today';
>                    return false;
>        }
>                reason = '';
>                return true;
>            }
>            else {
>                reason = 'valid format but an invalid date';
>                return false;
>            }
>        }
>        else {
>            reason = 'invalid separators';
>            return false;
>        }
>}
>else {
>        reason = 'invalid length';
>        return false;
>    }
>}
>
>
>