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 have this jquery code inside my wordpress admin page that checks if the input value is empty.


     var link = $j('#input').val();
    if(link == ''){
         alert('hi there');



Now if the form is empty it will alert ' hi there'.

the plugin works fine but the alert does not show on the main page. Only in the admin section.

what would be the problem?

here is how I am calling jquery.

function test(){
wp_enqueue_script('myscript', plugin_dir_url(__FILE__). 'js/test.js');


I would like that if the value of input is empty, the alert show also in the wordpress homepage and not only in the admin page.

share|improve this question
The first bit of javascript is where exactly? In your test.js file? – Wyck Jun 21 '12 at 16:05
yes Wyck thats test.js – Ronny Jun 21 '12 at 16:33
function test(){
    wp_enqueue_script('myscript', plugin_dir_url(__FILE__). 'js/test.js',array('jquery'));
share|improve this answer
added that, but same thing Gembel. the alert only shows at the admin page. – Ronny Jun 21 '12 at 16:39
hmm.. not sure why. is your js appear when you view page source? just in case you forget to add wp_head(); in your template :D – Gembel Intelek Jun 21 '12 at 16:48
yes it does appear Gembel. – Ronny Jun 21 '12 at 16:57
how about testing your js in jsbin? here is my test jsbin.com/omumit/edit#javascript,html – Gembel Intelek Jun 21 '12 at 17:54

I believe the problem is that you are enquequeing jquery.

You don't need to do that, as WordPress does it by default. Just remove


and everything should be fine.

share|improve this answer
that will never work. this is a plugin and I am calling jquery. – Ronny Jun 21 '12 at 16:32
But you do not need to call jQuery! Trust me, I have recently submited plugin to WordPress.org and before approving it, I needed to remove jQuery call. There is no need for calling jQuery with plugins! – OriginalEXE Jun 21 '12 at 16:35
ok well... gave that a shot too.. no changes. – Ronny Jun 21 '12 at 16:40
What does your browser console say? – OriginalEXE Jun 21 '12 at 16:50

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.