0

I've been trying to figure out how to implement javascript on my registration page with no luck. I've read the documentation on wordpress about properly including js, have searched for relevant answers, and believe I have followed all steps correctly, however it's not working. Basically I call a .js file in functions.php, and it doesn't load in the page header.

Here is the implementation in functions.php (on line 156): http://pastebin.com/ZtK3Kw2E

Here is the js file contents:

function forceNumber(event){
var keyCode = event.keyCode ? event.keyCode : event.charCode;
if((keyCode < 48 || keyCode > 58) && keyCode != 8 && keyCode != 9 && keyCode != 32 &&     keyCode != 37 && keyCode != 39 && keyCode != 40 && keyCode != 41 && keyCode != 43 &&     keyCode != 45 && keyCode != 46)
return false;
}

Here is the page it is implemented on: https://jannus.org/wp-login.php?action=register

Again, it seems as if I followed the directions correctly but the page does not seem to be loading the file.

Any assistance on this would be greatly appreciated! Also, thank you for opening a stack forum for wordpress!

Kindly, Helena

1 Answer 1

2

You should use login_enqueue_scripts hook and not wp_enqueue_scripts to place JS files on login/register page.

On line 159 of your file change:

add_action( 'wp_enqueue_scripts', 'forceNumber' );

to:

add_action( 'login_enqueue_scripts', 'forceNumber' );

And it should work just fine.

2
  • I would vote you up but I don't yet have the reputation to. :(
    – Helena
    Jun 19, 2013 at 7:27
  • You're welcome :) I'm glad I could help :) Jun 19, 2013 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.