WordPress.org

Make WordPress Core

Opened 9 years ago

Last modified 8 weeks ago

#15204 reopened enhancement

JavaScript Validation should trim values and set focus on invalid field

Reported by: batmoo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.1
Component: Taxonomy Keywords: needs-patch, bulk-reopened
Focuses: javascript Cc:

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 9 years ago.
15204_v2.diff (2.3 KB) - added by batmoo 8 years ago.

Download all attachments as: .zip

Change History (13)

@batmoo
9 years ago

#1 @batmoo
9 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.

#2 @nacin
8 years ago

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

@batmoo
8 years ago

#3 @batmoo
8 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 :)

#4 @batmoo
8 years ago

  • Keywords ux-feedback added

#5 @mdawaffe
8 years ago

  • Milestone changed from Awaiting Review to Future Release

#6 @nacin
5 years ago

  • Component changed from Validation to Taxonomy
  • Focuses javascript added
  • Milestone changed from Future Release to 3.9

#7 @bassgang
5 years ago

@batmoo can you provide more context to your description where the validation exactly happens?
Furthermore I doubt that the ticket still is a "defect (bug)", would not be "enhancement" as ticket type more appropriate?

#8 @nacin
5 years ago

  • Keywords needs-patch added; has-patch ux-feedback removed
  • Milestone changed from 3.9 to Future Release

This JS is still really dense; I'm not positive it's all fine and dandy, and given it's been three years, I doubt batmoo would know either. :-( Moving to Future, would be nice to fix this of course. Sorry for having delayed it three years ago.

#9 @chriscct7
4 years ago

  • Type changed from defect (bug) to enhancement

#10 @iseulde
4 months ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from assigned to closed

This ticket has not seen any activity in over *two* years, so I'm closing it as "wontfix".

The ticket may lack decisiveness, may have become irrelevant, or may not have gathered enough interest.

If you think this ticket does deserve some attention again, feel free to reopen.

For bugs, it would be great if you could provide updated steps to reproduce against the latest version of WordPress (5.0.2 at the time of writing). Remember images or a video can be superior to explain a problem. At the very least, quickly test again to make sure the bug still exists.

If it’s an enhancement or feature, some extra motivation may help.

Thank you for your contributions to WordPress! <3

#11 @JeffPaul
8 weeks ago

  • Keywords bulk-reopened added
  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened

A decision was made to reopen tickets that were closed in the bulk edit that this ticket was affected by. This ticket is being placed back into the Awaiting Review milestone so it can be individually evaluated and verified to determine if it is still relevant/valid or reproducible.

Note: See TracTickets for help on using tickets.