| 11 | |
| 12 | |
| 13 | So we can add a function that directly imports JavaScript code to the login page and loads it there. |
| 14 | {{{#!php |
| 15 | <?php |
| 16 | function add_custom_login_script() { |
| 17 | wp_enqueue_script('custom-login-script', get_stylesheet_directory_uri() . '/js/custom-login-script.js', array('jquery'), '1.0', true); |
| 18 | } |
| 19 | add_action('login_enqueue_scripts', 'add_custom_login_script'); |
| 20 | |
| 21 | }}} |
| 22 | |
| 23 | Then we can add jQuery/JS code |
| 24 | |
| 25 | |
| 26 | {{{ |
| 27 | jQuery(document).ready(function($) { |
| 28 | var passwordField = $('#user_pass'); |
| 29 | var capsLockAlert = $('<div id="caps-lock-alert">Caps Lock is currently on.</div>').hide(); |
| 30 | |
| 31 | passwordField.after(capsLockAlert); |
| 32 | |
| 33 | passwordField.on('keyup', function(event) { |
| 34 | var capsLockStatus = event.getModifierState && event.getModifierState('CapsLock'); |
| 35 | |
| 36 | if (capsLockStatus) { |
| 37 | capsLockAlert.show(); |
| 38 | } else { |
| 39 | capsLockAlert.hide(); |
| 40 | } |
| 41 | }); |
| 42 | }); |
| 43 | |
| 44 | }}} |
| 45 | |