Summary: | Transport cost matrix needs form validation | ||
---|---|---|---|
Product: | Koha | Reporter: | Brendan Lawlor <blawlor> |
Component: | System Administration | Assignee: | Bugs List <koha-bugs> |
Status: | NEW --- | QA Contact: | Testopia <testopia> |
Severity: | major | ||
Priority: | P5 - low | CC: | blawlor, gmcharlt, lucas |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40655 | ||
GIT URL: | Change sponsored?: | --- | |
Patch complexity: | --- | Documentation contact: | |
Documentation submission: | Text to go in the release notes: | ||
Version(s) released in: | Circulation function: | ||
Attachments: | Bug 40948: Add form validation to transport cost matrix |
Description
Brendan Lawlor
2025-10-03 14:06:10 UTC
Created attachment 187409 [details] [review] Bug 40948: Add form validation to transport cost matrix Attaching this patch for feedback. It replaces the js alert with html form validation using the pattern attribute and a regular expression. It sets the input as required so you cannot submit an empty value. The pattern matches numeric values with up to two decimal places. Allows: 0 - zero 100 - integers 0.5 - leading 0 before a demical place .5 - single decimal place 20.75 - two decimal places Rejects: 001 - leading zeros before integer 10. - no digits after decimal 5.255 - three decimal places I also thought about making this a number type input with step=".01" Custom validation with Bootstrap might be nice too, but this was the simplest solution. Another thought is that we could still trigger the form validation on blur of the input so that the user would get immediate feedback for the field as soon as they finish editing it like: $("body").on("blur", ".cost_input", function () { if ( ! $('#cost_matrix_form')[0].checkValidity() ) { $('#cost_matrix_form')[0].reportValidity(); } }); Brendan, is this ready for testing? (In reply to Lucas Gass (lukeg) from comment #4) > Brendan, is this ready for testing? I didn't set this to needs sign off only because I'm not sure if this is the best solution, but it does work. From a ux point of view I think the onblur listener actually is a good idea, especially since a user could be editing many cells incorrectly before they submit the form. So I had the thought to add the onblur listener back, but instead of the alert it could check if the form is valid. The matrix is a tricky form because it's so dense. I'm not sure if the default html validation pop ups function as well here as they do on a more normal looking form, but it does the basic job of preventing unwanted values. I'd appreciate any feedback to consider the best way forward with this one. Thanks! |