Bug 14060 - Remove readonly on date inputs
Summary: Remove readonly on date inputs
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
: 10995 11448 (view as bug list)
Depends on:
Blocks: 16796 17524 18469
  Show dependency treegraph
 
Reported: 2015-04-24 13:36 UTC by Jonathan Druart
Modified: 2017-12-07 22:20 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 14060: Remove readonly attributes on date inputs (21.31 KB, patch)
2015-04-24 14:00 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add OnClose event on missing datepicker (3.16 KB, patch)
2015-04-27 08:43 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Display the date format on the warning popup (1.74 KB, patch)
2015-04-27 08:43 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Remove readonly attributes on date inputs (21.14 KB, patch)
2015-11-06 10:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add OnClose event on missing datepicker (3.16 KB, patch)
2015-11-06 10:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Display the date format on the warning popup (1.74 KB, patch)
2015-11-06 10:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Force the input to contain a valid date (6.10 KB, patch)
2015-12-01 17:35 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add support for dmydot (957 bytes, patch)
2016-01-04 11:04 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Remove readonly attributes on date inputs (21.53 KB, patch)
2016-08-19 10:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add OnClose event on missing datepicker (3.27 KB, patch)
2016-08-19 10:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Display the date format on the warning popup (1.74 KB, patch)
2016-08-19 10:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Force the input to contain a valid date (6.13 KB, patch)
2016-08-19 10:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add support for dmydot (957 bytes, patch)
2016-08-19 10:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Remove readonly attributes on date inputs (21.53 KB, patch)
2016-08-26 07:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add OnClose event on missing datepicker (3.27 KB, patch)
2016-08-26 07:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Display the date format on the warning popup (1.74 KB, patch)
2016-08-26 07:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Force the input to contain a valid date (6.13 KB, patch)
2016-08-26 07:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add support for dmydot (957 bytes, patch)
2016-08-26 07:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Display date format pattern instead of date format name (1.49 KB, patch)
2016-08-26 07:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Force leading zeros on date (1.78 KB, patch)
2016-08-30 08:57 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Add the datepicker class to dateofbirth (1.32 KB, patch)
2016-08-30 08:57 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Remove readonly attributes on date inputs (21.63 KB, patch)
2016-08-30 13:05 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Add OnClose event on missing datepicker (3.37 KB, patch)
2016-08-30 13:05 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Display the date format on the warning popup (1.84 KB, patch)
2016-08-30 13:05 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Force the input to contain a valid date (6.24 KB, patch)
2016-08-30 13:05 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Add support for dmydot (1.04 KB, patch)
2016-08-30 13:06 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Display date format pattern instead of date format name (1.59 KB, patch)
2016-08-30 13:06 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Force leading zeros on date (1.89 KB, patch)
2016-08-30 13:06 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14060: Add the datepicker class to dateofbirth (1.42 KB, patch)
2016-08-30 13:06 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 14060: Consider an empty string as a valid date (1.11 KB, patch)
2016-09-05 08:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Improve regex to limit year to 4 integers (1.67 KB, patch)
2016-09-06 11:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14060: Remove readonly attributes on date inputs (21.63 KB, patch)
2016-09-06 12:25 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Add OnClose event on missing datepicker (3.38 KB, patch)
2016-09-06 12:25 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Display the date format on the warning popup (1.84 KB, patch)
2016-09-06 12:25 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Force the input to contain a valid date (6.24 KB, patch)
2016-09-06 12:25 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Add support for dmydot (1.04 KB, patch)
2016-09-06 12:26 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Display date format pattern instead of date format name (1.59 KB, patch)
2016-09-06 12:26 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Force leading zeros on date (1.89 KB, patch)
2016-09-06 12:26 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Add the datepicker class to dateofbirth (1.42 KB, patch)
2016-09-06 12:27 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Consider an empty string as a valid date (1.16 KB, patch)
2016-09-06 12:27 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 14060: Improve regex to limit year to 4 integers (1.72 KB, patch)
2016-09-06 12:27 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2015-04-24 13:36:21 UTC
Currently some inputs use datepicker (or datetimepicker) with a readonly attributes.
That can cause accessibility issues.
Comment 1 Jonathan Druart 2015-04-24 14:00:08 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2015-04-24 14:05:25 UTC
*** Bug 10995 has been marked as a duplicate of this bug. ***
Comment 3 Marc Véron 2015-04-26 07:51:37 UTC
Maybe the current date format could be displayed in the alert message?
Something like:
 	
alert(MSG_PLEASE_ENTER_A_VALID_DATE '('+ dateformat + ')');

---
I found following place without validation:

Go to Detail of a patron with hold(s)
Select Tab Hold
Date field near "Suspend all holds until" allows wrong date format, e.g. "12345678"
Comment 4 Jonathan Druart 2015-04-27 08:43:47 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2015-04-27 08:43:53 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2015-04-27 08:47:47 UTC
*** Bug 11448 has been marked as a duplicate of this bug. ***
Comment 7 Nicole C. Engard 2015-10-30 18:43:37 UTC
g13:42 ~/kohaclone (master % u=)$ git qa 14060
Note: checking out 'origin/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at fd12390... Bug 15010: Import patron tool creates 'duplicate' restrictions ( debarments )
Branch bug14060-qa set up to track remote branch master from origin.
Switched to a new branch 'bug14060-qa'
Bug 14060 - Remove readonly on date inputs

38484 - Bug 14060: Remove readonly attributes on date inputs
38540 - Bug 14060: Add OnClose event on missing datepicker
38541 - Bug 14060: Display the date format on the warning popup

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 14060: Remove readonly attributes on date inputs
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc
Auto-merging koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
Auto-merging koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc
Applying: Bug 14060: Add OnClose event on missing datepicker
Applying: Bug 14060: Display the date format on the warning popup
13:43 ~/kohaclone (bug14060-qa % u+3)$
Comment 8 Jonathan Druart 2015-11-06 10:18:05 UTC Comment hidden (obsolete)
Comment 9 Jonathan Druart 2015-11-06 10:18:13 UTC Comment hidden (obsolete)
Comment 10 Jonathan Druart 2015-11-06 10:18:20 UTC Comment hidden (obsolete)
Comment 11 Owen Leonard 2015-11-24 19:20:07 UTC
Testing with date format "MM/DD/YYYY":

In the "specify due date" field I was able to enter "11/1/2015" without any error. When I checked out the item it ignored the invalid date and used the default due date.

In the "Renewal due date" field I was able to enter "11/1/2015" without any error. When I clicked the renew button the AJAX renewal process was started but never finished. Firebug reveals the error in the AJAX response:

"The given date (11/1/2007) does not match the date format (us) at /home/oleonard/kohaclone/Koha/DateUtils.pm line 153."
Comment 12 Jonathan Druart 2015-11-25 11:00:10 UTC
Hi Owen,
Could you detail how you managed to insert an invalid date?
Comment 13 Owen Leonard 2015-12-01 14:58:00 UTC
(In reply to Jonathan Druart from comment #12)
> Could you detail how you managed to insert an invalid date?

I typed it in the date input field.
Comment 14 Jonathan Druart 2015-12-01 17:35:16 UTC Comment hidden (obsolete)
Comment 15 Jonathan Druart 2015-12-01 17:35:53 UTC
(In reply to Owen Leonard from comment #13)
> (In reply to Jonathan Druart from comment #12)
> > Could you detail how you managed to insert an invalid date?
> 
> I typed it in the date input field.

Indeed :)
I was using another version of the code.
Comment 16 Marc Véron 2016-01-02 14:11:01 UTC
Hi Jonathan,

Sorry, I found following issues:

1)
Syspref dateformat = dmydot (01.10.2017) is not covered by the function is_valid_date

Symptom 1:
  - Set syspref dateformat to dmydot, clear browser chache
  - Try to add a manual restriction on moremember.pl
  - manually enter 26.01.2017
  - hit 'Add restriction'
    Result: restriction is added with empty date = indefinite restriction.

Symptom 2:
  - manually enter 1.1.2018
  - hit enter
  - Message appears "Please enter valid date...", closes automatically after ca. 1 second
    Result: restriction is added with empty date = indefinite restriction.


2)
Software error in following cases

Case 1:
  - Set syspref dateformat to dd/mm/yyyy, clear browser cache
  - manually enter 1/10/2017
  - hit 'Add restriction'
  Result: Software error: The given date (1/10/2017) does not match the date format (metric) at /usr/share/kohaclone/Koha/DateUtils.pm line 153.

Case 2:
  - Set syspref to yyyy-mm-dd
  - manually enter 2017-2-2
  - hit 'Add Restiction'
  Result: Software error: The given date (2018-2-2) does not match the date format (iso) at /usr/share/kohaclone/Koha/DateUtils.pm line 153.

It seems that the timepicker's function parseDate accepts such dates.
Comment 17 Jonathan Druart 2016-01-04 11:04:10 UTC Comment hidden (obsolete)
Comment 18 Jonathan Druart 2016-01-04 11:05:29 UTC
(In reply to Marc Véron from comment #16)
> Hi Jonathan,
> 
> Sorry, I found following issues:
> 
> 1)
> Syspref dateformat = dmydot (01.10.2017) is not covered by the function
> is_valid_date
> 
> Symptom 1:
>   - Set syspref dateformat to dmydot, clear browser chache
>   - Try to add a manual restriction on moremember.pl
>   - manually enter 26.01.2017
>   - hit 'Add restriction'
>     Result: restriction is added with empty date = indefinite restriction.
> 
> Symptom 2:
>   - manually enter 1.1.2018
>   - hit enter
>   - Message appears "Please enter valid date...", closes automatically after
> ca. 1 second
>     Result: restriction is added with empty date = indefinite restriction.


Should be fixed with the last patch.

> 2)
> Software error in following cases
> 
> Case 1:
>   - Set syspref dateformat to dd/mm/yyyy, clear browser cache
>   - manually enter 1/10/2017
>   - hit 'Add restriction'
>   Result: Software error: The given date (1/10/2017) does not match the date
> format (metric) at /usr/share/kohaclone/Koha/DateUtils.pm line 153.
> 
> Case 2:
>   - Set syspref to yyyy-mm-dd
>   - manually enter 2017-2-2
>   - hit 'Add Restiction'
>   Result: Software error: The given date (2018-2-2) does not match the date
> format (iso) at /usr/share/kohaclone/Koha/DateUtils.pm line 153.
> 
> It seems that the timepicker's function parseDate accepts such dates.

I don't manage to force the leading zeros, suggestions are welcome.
Comment 19 Marc Véron 2016-01-27 21:33:03 UTC
(In reply to Jonathan Druart from comment #18)
(...)
> I don't manage to force the leading zeros, suggestions are welcome.

The date validation seems to be on the datepicker's onClose and change functions only, but there is no onclick function directly on the Submit button. I think that a final date validation could take place there with a function that returns false if the date is not valid. Maybe the same function could try to do some formatting (1/1/2016 -> 01/01/2016  etc.) before validation.
Comment 20 Katrin Fischer 2016-02-23 22:15:13 UTC
I'd really like to see this moving forward. So, if I understand correctly, the current problem is that the validation is not triggered, when you enter the date without using the datepicker?
Comment 21 Marc Véron 2016-02-24 14:48:32 UTC
(In reply to Katrin Fischer from comment #20)
> I'd really like to see this moving forward. So, if I understand correctly,
> the current problem is that the validation is not triggered, when you enter
> the date without using the datepicker?

Hi Katrin,

That seems to be one of the problems, but I think some problems hide other ones.

I write down som notes I did while playing with the code, just pro memoria.

One finding is that in borrower_debarments.inc, the id manual_restriction_form is not on the form, but on the fieldset:
 <fieldset class="rows" id="manual_restriction_form">

After moving the form tag, I was able to add a validation to the form, something like:
            mrform.on("submit",function(e) {
                var testDate = $("#rexpiration").val();
                if (!validate_date( testDate )) {
                    e.preventDefault();
                    return false;
                }
                return true;
            }); 


Then I tweaked is_valid_date(date) to return false if it gets dates like 1.1.2014 etc. (depending on the dateformat syspref), something like:

function is_valid_date(date) {
    var dateformat = dateformat_str = '[% Koha.Preference('dateformat') %]';
    if ( dateformat == 'us' ) {
        if (! date.match('[0-9]{2}/[0-9]{2}/[0-9]{4}') )
            return 0;
        dateformat = 'mm/dd/yy';
        dateformat_str = 'mm/dd/yyyy';
    } else if ( dateformat == 'metric' ) {
        if (! date.match('[0-9]{2}/[0-9]{2}/[0-9]{4}') )
            return 0;
        dateformat = 'dd/mm/yy';
        dateformat_str = 'dd/mm/yyyy';
    } else if (dateformat == 'iso' ) {
        if (! date.match('[0-9]{2}-[0-9]{2}-[0-9]{4}') )
            return 0;
        dateformat = 'yy-mm-dd';
        dateformat_str = 'yyyy-mm-dd';
    } else if ( dateformat == 'dmydot' ) {
        if (! date.match('[0-9]{2}.[0-9]{2}.[0-9]{4}') )
            return 0;
        dateformat = 'dd.mm.yy';
        dateformat_str = 'dd.mm.yyyy';
    }
    try {
        $.datepicker.parseDate(dateformat, date);
    } catch (e) {
        return 0;
    };
    return 1;
}

Then I tweaked the function validate_date to return true / false (in calendar.inc)

function validate_date (dateText, inst) {
    if ( !is_valid_date(dateText) ) {
        var dateformat_str = '[% Koha.Preference('dateformat') %]';
        alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str));
        if (inst) {
            $('#'+inst.id).val('');
        }
        return 0;
    }
    return 1;
}

(The if (inst) was to avoid a JavaScript error)


Now I could trigger the validation. But one problem now was that empty dates could no longer be saved.

I have no more time at the moment to dig deeper, but maybe the notes can help somebody else to find a solution.
Comment 22 Katrin Fischer 2016-02-24 14:51:50 UTC
Adding Owen... maybe he has an idea about the client side Javascript checks
Comment 23 Marc Véron 2016-06-22 07:58:22 UTC
For the records: jQuery Validation Plugin's date method is no option, it would consider 30/30/2008 as a valid date.
"Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js)." See: https://jqueryvalidation.org/date-method
Comment 24 Marc Véron 2016-06-22 08:25:01 UTC
For the records:

koha-tmpl/intranet-tmpl/prog/js/members.js
(...)
// this function checks id date is like DD/MM/YYYY
function CheckDate(field)
(...)

Used in:

koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
for fields dateenrolled and dateexpiry
(only if dateformat == "metric" )
Comment 25 Jonathan Druart 2016-06-23 12:05:17 UTC
I think this version should be push as it, and follow-ups could come later...
Comment 26 Jonathan Druart 2016-08-19 10:08:00 UTC Comment hidden (obsolete)
Comment 27 Jonathan Druart 2016-08-19 10:08:06 UTC Comment hidden (obsolete)
Comment 28 Jonathan Druart 2016-08-19 10:08:12 UTC Comment hidden (obsolete)
Comment 29 Jonathan Druart 2016-08-19 10:08:16 UTC Comment hidden (obsolete)
Comment 30 Jonathan Druart 2016-08-19 10:08:21 UTC Comment hidden (obsolete)
Comment 31 Jonathan Druart 2016-08-19 10:10:04 UTC
(In reply to Jonathan Druart from comment #25)
> I think this version should be push as it, and follow-ups could come later...

No discussion and what I proposed is the only suggestion, so I switch the status back to needs signoff.
Comment 32 Owen Leonard 2016-08-25 16:06:23 UTC
I'm getting a JavaScript error on returns.pl:

SyntaxError: expected expression, got ','
$("#barcode").focus(); },

Is it possible for the error message to use the date format pattern instead of the date format name? It's not very clear for the alert to say

"Please enter a valid date (should match us)."

It would be better to see:

"Please enter a valid date (should match MM/DD/YYYY)."

Other than that, this seems to be working really well.
Comment 33 Jonathan Druart 2016-08-26 07:45:08 UTC Comment hidden (obsolete)
Comment 34 Jonathan Druart 2016-08-26 07:45:12 UTC Comment hidden (obsolete)
Comment 35 Jonathan Druart 2016-08-26 07:45:16 UTC Comment hidden (obsolete)
Comment 36 Jonathan Druart 2016-08-26 07:45:19 UTC Comment hidden (obsolete)
Comment 37 Jonathan Druart 2016-08-26 07:45:24 UTC Comment hidden (obsolete)
Comment 38 Jonathan Druart 2016-08-26 07:45:30 UTC Comment hidden (obsolete)
Comment 39 Owen Leonard 2016-08-29 18:11:42 UTC
- With my date format preference set to US (mm/dd/yyyy) it accepts dates like 3/3/2016. Sometimes saving this date triggers an error in Koha, sometimes the date is ignored (and no date is saved).

- With my date format preference set to dmydot (dd.mm.yyyy) it accepts dates like 1.1.2016 without any warning, but the date which is saved does not match (in this case, 12.09.2016). The same thing happens with dd/mm/yyyy, including the saved date -- 12/09/2016.

- I'm getting no warnings on the patron edit page when adding invalid data to the date of birth field. It works correctly with registration date and expiration date.
Comment 40 Jonathan Druart 2016-08-30 08:57:23 UTC Comment hidden (obsolete)
Comment 41 Jonathan Druart 2016-08-30 08:57:27 UTC Comment hidden (obsolete)
Comment 42 Owen Leonard 2016-08-30 13:05:20 UTC Comment hidden (obsolete)
Comment 43 Owen Leonard 2016-08-30 13:05:33 UTC Comment hidden (obsolete)
Comment 44 Owen Leonard 2016-08-30 13:05:46 UTC Comment hidden (obsolete)
Comment 45 Owen Leonard 2016-08-30 13:05:56 UTC Comment hidden (obsolete)
Comment 46 Owen Leonard 2016-08-30 13:06:06 UTC Comment hidden (obsolete)
Comment 47 Owen Leonard 2016-08-30 13:06:18 UTC Comment hidden (obsolete)
Comment 48 Owen Leonard 2016-08-30 13:06:30 UTC Comment hidden (obsolete)
Comment 49 Owen Leonard 2016-08-30 13:06:40 UTC Comment hidden (obsolete)
Comment 50 Nick Clemens 2016-08-31 16:57:54 UTC
This all works very well, I can't enter any errors, I can press enter with an invalid date, but it reads it as empty so that seems okay.

My one complaint would be that if you click into the datepicker, and decide not to enter a date you should not receive the warning. That is, closing on an empty value should not warn
Comment 51 Jonathan Druart 2016-09-05 08:16:39 UTC Comment hidden (obsolete)
Comment 52 Jonathan Druart 2016-09-05 08:17:12 UTC
(In reply to Nick Clemens from comment #50)
> This all works very well, I can't enter any errors, I can press enter with
> an invalid date, but it reads it as empty so that seems okay.
> 
> My one complaint would be that if you click into the datepicker, and decide
> not to enter a date you should not receive the warning. That is, closing on
> an empty value should not warn

Heh, good catch!
Comment 53 Nick Clemens 2016-09-06 10:26:39 UTC
Hmm..and now one more I ran across:

At checkout, specify due date of: January 1, 01984

No error on setting this date, but attempting to checkout gives an invalid date error.

Checking in items you can set and keep 01/01/01984 and items are marked as returned 0198-01-01 00:00:00

I am not sure if these dates should be handled, or simply rejected (I think the latter)
Comment 54 Jonathan Druart 2016-09-06 11:59:25 UTC Comment hidden (obsolete)
Comment 55 Mirko Tietgen 2016-09-06 12:04:13 UTC
(In reply to Jonathan Druart from comment #54)
> Created attachment 55246 [details] [review] [review]
> Bug 14060: Improve regex to limit year to 4 integers
> 
> 01/01/01984 should not be considered as a valid date.

I hope Koha stays free software until the year 10000, or this will lead to some library having to sponsor a new ILS again.
Comment 56 Nick Clemens 2016-09-06 12:25:14 UTC
Created attachment 55247 [details] [review]
Bug 14060: Remove readonly attributes on date inputs

In order to remove accessibility issues due to the readonly attributes
on date inputs, this patch will remove them and introduce a javascript
validation on them.

This patch is not perfect for some reason:
I didn't manage to force the user to select a valid date. One solution
would be to reopen the datepicker plugin until a valid date is inserted.
But it could be annoying for users (and for me: I did not manage to
implement this solution).
You will note that input is emptied if the date is not valid. This is a
quick and efficient solution to prevent submitting invalid date and make
Koha explodes. A proper solution would be to implement the check server
side send a friendly message to the user.

Test plan:
For all inputs, try an invalid and a valid date.
 1/ Debar a patron
 2/ On the checkout tables (circulation and moremember), add a renewal
due date (at the bottom of the tables)
 3/ On the checkout page, specify a due date
 4/ On the return page, specify a return date
 5/ On the invoice page (acquisition module), enter a shipment and
billing date
 6/ On the invoice search page (invoices.pl) use filters shipment and
billing dates
 7/ On the offline circ page, specify a due date
 8/ On the edit patron page (memberentry), add a debarment
 9/ On the reserve page (reserve/request.pl), use the date inputs to
suspend until a defined date
10/ Edit patrons in a batch (tools/modborrowers.pl) and use the
registration and expiry date inputs

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 57 Nick Clemens 2016-09-06 12:25:24 UTC
Created attachment 55248 [details] [review]
Bug 14060: Add OnClose event on missing datepicker

The "suspend until" inputs (hold list on circ/circulation.pl and
members/moremember.pl) were not set in the same way.
The minDate option should be set for both (bug 10703 removed it for
circ/circulation.pl).
This patch reintroduces the option and add the OnClose event on both.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 58 Nick Clemens 2016-09-06 12:25:47 UTC
Created attachment 55249 [details] [review]
Bug 14060: Display the date format on the warning popup

The date format is now displayed on the warning popup.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 59 Nick Clemens 2016-09-06 12:25:57 UTC
Created attachment 55250 [details] [review]
Bug 14060: Force the input to contain a valid date

Before this patch, the user was still allowed to enter a valid date.
Now, if the date is not valid, the input is emptied.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 60 Nick Clemens 2016-09-06 12:26:19 UTC
Created attachment 55251 [details] [review]
Bug 14060: Add support for dmydot

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 61 Nick Clemens 2016-09-06 12:26:46 UTC
Created attachment 55252 [details] [review]
Bug 14060: Display date format pattern instead of date format name

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 62 Nick Clemens 2016-09-06 12:26:57 UTC
Created attachment 55253 [details] [review]
Bug 14060: Force leading zeros on date

If a date does not contain leading zeros for day and month, the date
will be refused.
parseDate function considers 1/1/1990 as a valid date, but our perl code
does not. We must refuse it.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 63 Nick Clemens 2016-09-06 12:27:05 UTC
Created attachment 55254 [details] [review]
Bug 14060: Add the datepicker class to dateofbirth

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 64 Nick Clemens 2016-09-06 12:27:12 UTC
Created attachment 55255 [details] [review]
Bug 14060: Consider an empty string as a valid date

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 65 Nick Clemens 2016-09-06 12:27:20 UTC
Created attachment 55256 [details] [review]
Bug 14060: Improve regex to limit year to 4 integers

01/01/01984 should not be considered as a valid date.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 66 Kyle M Hall 2016-09-08 13:04:07 UTC
Pushed to master for 16.11, thanks Jonathan!
Comment 67 Frédéric Demians 2016-10-22 06:50:10 UTC
Pushed in 16.05. Will be in 16.05.05.
Comment 68 MetaBiblioteca Colombia 2016-10-25 23:40:15 UTC
Hello,
I see an error when format  is an ISO (yyyy-mm-dd).
In the calendar.inf file the date format appears to: 

dateformat = 'yy-mm-dd'
but in a ISO format is  dateformat = 'yyyy-mm-dd'
four digits for year...
Comment 69 Jonathan Druart 2016-10-26 07:21:23 UTC
(In reply to MetaBiblioteca Colombia from comment #68)
> Hello,
> I see an error when format  is an ISO (yyyy-mm-dd).
> In the calendar.inf file the date format appears to: 
> 
> dateformat = 'yy-mm-dd'
> but in a ISO format is  dateformat = 'yyyy-mm-dd'
> four digits for year...

can you please specify the page and date you tried?
What kind of error do you get?
Comment 70 Jonathan Druart 2016-10-31 14:45:32 UTC
(In reply to MetaBiblioteca Colombia from comment #68)
> Hello,
> I see an error when format  is an ISO (yyyy-mm-dd).
> In the calendar.inf file the date format appears to: 
> 
> dateformat = 'yy-mm-dd'
> but in a ISO format is  dateformat = 'yyyy-mm-dd'
> four digits for year...

See bug 17524 for a patch.