WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/01/2007 06:23:16 AM (14 years ago)
Author:
ryan
Message:

JS/AJAX form validation from mdawaffe. fixes #5299

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/user.php

    r6188 r6303  
    8383    do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 ));
    8484
    85     if (!$update ) {
    86         if ( $pass1 == '' || $pass2 == '' )
    87             $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ));
    88     } else {
    89         if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) )
    90             $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ));
     85    if ( $update ) {
     86        if ( empty($pass1) && !empty($pass2) )
     87            $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass1' ) );
     88        elseif ( !empty($pass1) && empty($pass2) )
     89            $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass2' ) );
     90    } else {
     91        if ( empty($pass1) )
     92            $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password.' ), array( 'form-field' => 'pass1' ) );
     93        elseif ( empty($pass2) )
     94            $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ), array( 'form-field' => 'pass2' ) );
    9195    }
    9296
    9397    /* Check for "\" in password */
    9498    if( strpos( " ".$pass1, "\\" ) )
    95         $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ));
     99        $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
    96100
    97101    /* checking the password has been typed twice the same */
    98102    if ( $pass1 != $pass2 )
    99         $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.' ));
     103        $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) );
    100104
    101105    if (!empty ( $pass1 ))
     
    110114    /* checking e-mail address */
    111115    if ( empty ( $user->user_email ) ) {
    112         $errors->add( 'user_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ));
     116        $errors->add( 'user_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) );
    113117    } else
    114118        if (!is_email( $user->user_email ) ) {
    115             $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ));
     119            $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) );
    116120        }
    117121
Note: See TracChangeset for help on using the changeset viewer.