Tytan888 / CSSWENG-S11-G1

0 stars 0 forks source link

Field validation: Trailing/Leading white spaces #6

Closed rpineda26 closed 11 months ago

rpineda26 commented 11 months ago

💾 Description: String fields such as project name, location, description, etc must not be set to empty. However, a workaround is by setting the field into a single space character " " so the validation considers the field as not empty and the form can be submitted. This must be fixed so that the validation will also consider fields with white space invalid.

⏰ Expected Outcome: The field validation should make sure that a String field containing only white spaces such as the space character " " is considered not a valid input. The form must be prevented from being submitted and appropriate warnings be produced.

☎️ Actual Outcome: Filling up a String entry with only white spaces is currently considered valid.

🎶 Steps to Reproduce:

  1. Add or edit a project (or any other model).
  2. Enter a space character " " in a String field and make sure all the remaining fields are valid. image
  3. submit the form and check the added/updated project in the database or from the admin view. image
  4. You can also check the project in the user view of the web app.
Tytan888 commented 11 months ago

🛠️ Fix: Fixed this bug by using JavaScript's trim() function on all text fields before validation. This will ensure that any text fields with empty spaces are flagged as invalid by the validator.

New Output/Behavior:

  1. Even if the admin tries to input a text field solely with empty spaces... image
  2. The page now properly flags it as invalid. image
  3. Also removing any leading and trailing spaces from all text fields. image