$(document).ready(function(){
        $(".submitbutton").live('click', function(){
         var isFormValid = true;

        $("input.req").each(function(){
            if ($.trim($(this).val()).length == 0){

                isFormValid = false;
            }

        });
         $("textarea.req").each(function(){
            if ($.trim($(this).val()).length == 0){

                isFormValid = false;
            }

        });

        if (!isFormValid)
        {
           alert("Please fill in all the required fields (indicated by *)");
        }
        else
        {
        
            var code = $("#code_answer").attr("value");
            var typed = $("#code").val();
            if(code == typed)
            {
               $('#contact').submit();
            }
            else
            {
               alert("The code you typed is not the code shown");
            }

        }


});




});


     
     
     







