fix: Stricter "donation amount" validation on the front end
This branch was written up a few days ago but accidentally kept from being pushed to origin.
User feedback noted that it was possible to set the donation amount value to something invalid - and while this is caught by form validation when the "submit" button is pressed, and while backend validation would also fail in this case, the user experience of having that invalid value persist while the rest of the form fills out is poor. (Especially because other fields will chide you if you mis-fill them as you go.)
This has been addressed in two ways, both in forms.py
:
- A
min
attribute has belatedly been added to thecustom_donation
input field, and is set when instantiated to theminimum_donation
value maintained by the Django settings file; - If a user enters an invalid value in that field, we leverage the browser validation API to ensure the ensuing error message shows the minimum donation value as USD. To this end, this commit defines new
oninvalid
andoninput
attributes oncustom_donation
, which simply toggle thecustomValidity
value of the field on and off.
This MR is based on another branch and should only be accepted after !114 (merged) is merged into main
.