[wp-trac] [WordPress Trac] #65281: Custom Time & Date Format Fields Allow Empty Save Instead of Validation
WordPress Trac
noreply at wordpress.org
Wed May 27 19:05:09 UTC 2026
#65281: Custom Time & Date Format Fields Allow Empty Save Instead of Validation
-------------------------------------------------+-------------------------
Reporter: ashirhabib | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Date/Time | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has-test- | Focuses:
info | administration
-------------------------------------------------+-------------------------
Comment (by westonruter):
Replying to [comment:3 westonruter]:
> Adding client-side validation as well would be welcome.
Here's a minimal patch which would address this:
{{{#!diff
diff --git a/src/wp-admin/options-general.php b/src/wp-admin/options-
general.php
index 6a9a6d2f38..5c2bae8731 100644
--- a/src/wp-admin/options-general.php
+++ b/src/wp-admin/options-general.php
@@ -67,7 +67,7 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
-<form method="post" action="options.php" novalidate="novalidate">
+<form method="post" action="options.php">
<?php settings_fields( 'general' ); ?>
<table class="form-table" role="presentation">
@@ -518,7 +518,7 @@ foreach ( $date_formats as $format ) {
/* translators: Hidden accessibility text. */
__( 'Custom date format:' ) .
'</label>' .
- '<input type="text" name="date_format_custom"
id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) )
. '" class="small-text" />' .
+ '<input type="text" name="date_format_custom"
id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) )
. '" class="small-text" required />' .
'<br />' .
'<p><strong>' . __( 'Preview:' ) . '</strong> <span
class="example">' . date_i18n( get_option( 'date_format' ) ) . '</span>' .
"<span class='spinner'></span>\n" . '</p>';
@@ -563,8 +563,8 @@ foreach ( $time_formats as $format ) {
/* translators: Hidden accessibility text. */
__( 'Custom time format:' ) .
'</label>' .
- '<input type="text" name="time_format_custom"
id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) )
. '" class="small-text" />' .
'<br />' .
+ '<input type="text" name="time_format_custom"
id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) )
. '" class="small-text" required />' .
'<p><strong>' . __( 'Preview:' ) . '</strong> <span
class="example">' . date_i18n( get_option( 'time_format' ) ) . '</span>' .
"<span class='spinner'></span>\n" . '</p>';
}}}
No need for custom JS.
Related: The `novalidate` attribute was removed from the comments form in
#47595.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/65281#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list