diff --git a/js/server_privileges.js b/js/server_privileges.js index 8fe721f51..ccf1eb0f1 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -8,32 +8,40 @@ /** * Validates the password field in a form * + * @uses jsPasswordEmpty + * @uses jsPasswordNotSame * @param object the form - * * @return boolean whether the field value is valid or not */ function checkPassword(the_form) { // Did the user select 'no password'? - if (typeof(the_form.elements['nopass']) != 'undefined' && the_form.elements['nopass'][0].checked) { + if (typeof(the_form.elements['nopass']) != 'undefined' + && the_form.elements['nopass'][0].checked) { return true; - } else if (typeof(the_form.elements['pred_password']) != 'undefined' && (the_form.elements['pred_password'].value == 'none' || the_form.elements['pred_password'].value == 'keep')) { + } else if (typeof(the_form.elements['pred_password']) != 'undefined' + && (the_form.elements['pred_password'].value == 'none' + || the_form.elements['pred_password'].value == 'keep')) { return true; } - // Validates - if (the_form.elements['pma_pw'].value == '') { - alert(jsPasswordEmpty); - the_form.elements['pma_pw2'].value = ''; - the_form.elements['pma_pw'].focus(); + var password = the_form.elements['pma_pw']; + var password_repeat = the_form.elements['pma_pw2']; + var alert_msg = false; + + if (password.value == '') { + alert_msg = jsPasswordEmpty; + } else if (password.value != password_repeat.value) { + alert_msg = jsPasswordNotSame; + } + + if (alert_msg) { + alert(alert_msg); + password.value = ''; + password_repeat.value = ''; + password.focus(); return false; - } else if (the_form.elements['pma_pw'].value != the_form.elements['pma_pw2'].value) { - alert(jsPasswordNotSame); - the_form.elements['pma_pw'].value = ''; - the_form.elements['pma_pw2'].value = ''; - the_form.elements['pma_pw'].focus(); - return false; - } // end if...else if + } return true; } // end of the 'checkPassword()' function diff --git a/js/user_password.js b/js/user_password.js deleted file mode 100644 index 3072db631..000000000 --- a/js/user_password.js +++ /dev/null @@ -1,44 +0,0 @@ -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * function used for password change form - * - * @version $Id$ - */ - -/** - * Validates the password field in a form - * - * @uses jsPasswordEmpty - * @uses jsPasswordNotSame - * @param object the form - * @return boolean whether the field value is valid or not - */ -function checkPassword(the_form) -{ - // Gets the elements pointers - // use password radio button - var use_pass = the_form.elements['nopass'][1].checked; - - // Validates - if (use_pass) { - var password = the_form.elements['pma_pw']; - var password_repeat = the_form.elements['pma_pw2']; - var alert_msg = false; - - if (password.value == '') { - alert_msg = jsPasswordEmpty; - } else if (password.value != password_repeat.value) { - alert_msg = jsPasswordNotSame; - } - - if (alert_msg) { - alert(alert_msg); - password.value = ''; - password_repeat.value = ''; - password.focus(); - return false; - } - } // end if (use_pass) - - return true; -} // end of the 'checkPassword()' function diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 9fe886c20..771c071bf 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -83,8 +83,7 @@ if (empty($GLOBALS['is_header_sent'])) { // js form validation stuff var jsHostEmpty = ''; diff --git a/user_password.php b/user_password.php index 96b163094..7c2f906e5 100644 --- a/user_password.php +++ b/user_password.php @@ -88,7 +88,7 @@ if (isset($nopass)) { * aren't valid -> displays the form */ // Loads the headers -$GLOBALS['js_include'][] = 'user_password.js'; +$GLOBALS['js_include'][] = 'server_privileges.js'; require_once './libraries/header.inc.php'; echo '

' . $strChangePassword . '

' . "\n\n";