Opened 3 years ago

Last modified 2 years ago

#15204 assigned defect (bug)

JavaScript Validation should trim values and set focus on invalid field

Reported by: batmoo Owned by:
Priority: normal Milestone: Future Release
Component: Validation Version: 3.1
Severity: normal Keywords: has-patch ux-feedback
Cc: batmoo@…

Description

If invalid fields are found after validation, focus should be placed on the first invalid field. Field values should be trimmed to check for truly empty values.

Also worth noting, the (mostly same) validateForm is located in both common.js and wpAjax.js.

Attachments (2)

15204.diff (2.2 KB) - added by batmoo 3 years ago.
15204_v2.diff (2.3 KB) - added by batmoo 3 years ago.

Download all attachments as: .zip

Change History (7)

batmoo3 years ago

  • Keywords has-patch added
  • Owner batmoo deleted
  • Status changed from new to assigned

Patch removes redundant validateForm from common.dev.js and uses the one in wp-ajax-response.js (though, in retrospect, it may be better to move it to a more agnostic place so that non-ajax submits can make use of it too).

Patch trims field values and sets focus on the first invalid field.

common will probably be enqueued in more places than wp-ajax-response. I imagine it may have been intentional for both to exist.

batmoo3 years ago

As far as I can tell, the only place that validateForm is in use is on tags.dev.js. Even then, it's redundant as almost all of the JS validation on the site is being handled by wp-ajax-response.

Regardless, new patch restores validateForm on common.dev.js, adds trim and focusing, and I've added some indentation to the functions to make them a bit more readable :)

  • Keywords ux-feedback added
  • Milestone changed from Awaiting Review to Future Release
Note: See TracTickets for help on using tickets.