WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 2 down vote accepted

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' );


add_action( 'login_enqueue_scripts', 'forceNumber' );

And it should work just fine.

share|improve this answer
Awesome! Thank you! It worked perfectly. – Helena Jun 19 '13 at 7:27
I would vote you up but I don't yet have the reputation to. :( – Helena Jun 19 '13 at 7:27
You're welcome :) I'm glad I could help :) – Krzysiek Dróżdż Jun 19 '13 at 7:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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