WordPress not using my javascript?

I’m trying to create ajax form submitting and validation with jQuery, but wordpress refuses to execute my code.

I’ve this snippet, working on http://jsfiddle.net

Read More
$(document).ready(function(){
    alert("Test");
    $('.sendbutton').click(function(){
        var nimi = $('input[name=nimi]').val();
        var viesti = $('textarea[name=viesti]').val();
        $('.control-group').removeClass("error");

        if(nimi == ""){
        $('.control-group#nimi').addClass("error");
        return false;    
        }
        if(viesti == ""){
        $('.control-group#viesti').addClass("error");
        return false;    
        }
        var message = $('#contact').serialize();
        alert(message);return false;
        $.ajax({
        data : message,
        error : function(){alert('Viestiäsi ei lähetetty. Yritä uudelleen?');},
        success : function(){alert('Onnistui');}




        });
        return false;
    });
});​

But it won’t work on wordpress, or on my theme. I’m using Roots theme (Twitter Bootstrap) and I’ve tried placing the code in plugins.js as jQuery UI is working and I placed it there, but no. Including the script from a different file

Related posts

Leave a Reply

1 comment