openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Add HTML validation to registration form

Open rebecca-shoptaw opened this issue 9 months ago • 2 comments

Closes #9244.

Feature. Adds HTML attributes to registration form inputs to prevent submission with improperly formatted data.

Technical

Implementation involved removing validate class to prevent duplicated realtime validation, and adding appropriate attributes to inputs in forms.py. Also involved triggering the HTML validation manually before the grecaptcha process, a strategy that will likely be re-used/expanded for part 2 of #9205.

Testing

  1. Log out (if logged in)
  2. Hit "Sign Up" or go to /account/create
  3. Try entering an improperly formatted password, username or email
  4. Ignore the on-screen warning and submit the form
  5. Submission should be prevented and you should see an HTML built-in error message pop up next to the first badly formatted input

Screenshot

Incorrect email format Incorrect username format Incorrect password length

Stakeholders

@cdrini

rebecca-shoptaw avatar May 09 '24 15:05 rebecca-shoptaw

tested on testing.openlibrary.org and I can't seem to get the email html error to appear 🤔

cdrini avatar May 13 '24 17:05 cdrini

tested on testing.openlibrary.org and I can't seem to get the email html error to appear 🤔

Update: Fixed! Was a result of grecaptcha blocking the validation. 🙂

rebecca-shoptaw avatar May 13 '24 20:05 rebecca-shoptaw

@cdrini sure thing!!

rebecca-shoptaw avatar May 23 '24 13:05 rebecca-shoptaw