Skip to content

fix: Stricter "donation amount" validation on the front end

stephen requested to merge stricter-donation-amount-validation into main

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:

  1. A min attribute has belatedly been added to the custom_donation input field, and is set when instantiated to the minimum_donation value maintained by the Django settings file;
  2. 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 and oninput attributes on custom_donation, which simply toggle the customValidity 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.

Merge request reports

Loading