WordPress.org

Make WordPress Core

Ticket #47064: 47064.diff

File 47064.diff, 2.8 KB (added by Yoonic, 2 years ago)
  • src/js/_enqueues/admin/common.js

    diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js
    index 2fc0c38828..d97b864e9f 100644
    a b $document.ready(function(){columns.init();}); 
    161161window.validateForm = function( form ) {
    162162        return !$( form )
    163163                .find( '.form-required' )
    164                 .filter( function() { return $( ':input:visible', this ).val() === ''; } )
     164                .filter( function() { return $( ':input:visible', this ).val().trim() === ''; } )
    165165                .addClass( 'form-invalid' )
    166166                .find( ':input:visible' )
    167167                .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
  • src/js/_enqueues/admin/user-profile.js

    diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js
    index 386f8ae593..a0e64098f7 100644
    a b  
    459459                }
    460460        } );
    461461
     462        /* Ensure nickname and mail are not empty */
     463        $( document ).on( 'submit', 'form', function(){
     464            if ( ! validateForm( this ) )
     465                    return false;
     466        } );
    462467})(jQuery);
  • src/wp-admin/user-edit.php

    diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php
    index f478c3be57..cc9f39c560 100644
    a b switch ( $action ) { 
    234234
    235235<hr class="wp-header-end">
    236236
    237 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"
     237<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate" class="validate"
    238238                                                                                        <?php
    239239                                                                                        /**
    240240                                                                                         * Fires inside the your-profile form tag on the user editing screen.
    endif; //!IS_PROFILE_PAGE 
    435435        <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
    436436</tr>
    437437
    438 <tr class="user-nickname-wrap">
     438<tr class="user-nickname-wrap form-required">
    439439        <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
    440440        <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
    441441</tr>
    endif; //!IS_PROFILE_PAGE 
    483483        <h2><?php _e( 'Contact Info' ); ?></h2>
    484484
    485485        <table class="form-table">
    486         <tr class="user-email-wrap">
     486        <tr class="user-email-wrap form-required">
    487487                <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
    488488                <td><input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text ltr" />
    489489                <?php