2015-09-30 2 views
0

Итак, я создаю контактную форму, и я пытаюсь создать скрипт проверки, и он не работает вообще, он даже не показывает ошибок. Он просто переходит к проверке по умолчанию.Скрипт проверки jQuery не работает вообще

Я просмотрел ресурсы, и файл JS загружен на страницу, но просто не работает ...?

jQuery.validator.addMethod("answercheck", function(e, t) { 
    return this.optional(t) || /^\bcat\b$/.test(e) 
}, "Please type the correct answer"), $(function() { 
    $("#contact").validate({ 
     rules: { 
      name: { 
       required: !0, 
       minlength: 2 
      }, 
      email: { 
       required: !0, 
       email: !0 
      }, 
      message: { 
       required: !0 
      }, 
      answer: { 
       required: !0, 
       answercheck: !0 
      } 
     }, 
     messages: { 
      name: { 
       required: "Please enter a name", 
       minlength: "Your name must consist of at least 2 characters" 
      }, 
      email: { 
       required: "Please enter an email" 
      }, 
      message: { 
       required: "Please enter a message", 
       minlength: "Please enter a longer message" 
      }, 
      answer: { 
       required: "Incorrect" 
      } 
     }, 
     submitHandler: function(form) { 
      $(form).ajaxSubmit({ 
       type:"POST", 
       data: $(form).serialize(), 
       url:"process.php", 
       success: function() { 
        $('#contact :input').attr('disabled', 'disabled'); 
        $('#contact').fadeTo("slow", 0.15, function() { 
         $(this).find(':input').attr('disabled', 'disabled'); 
         $(this).find('label').css('cursor','default'); 
         $('#success').fadeIn(); 
        }); 
       }, 
       error: function() { 
        $('#contact').fadeTo("slow", 0.15, function() { 
         $('#error').fadeIn(); 
        }); 
       } 
      }); 
     } 
    }); 
}); 
+0

вы можете предоставить скрипку? – Unlockedluca

+1

http://jsfiddle.net/arunpjohny/xmj590nj/1/? –

+0

Хорошо, поэтому по какой-то причине jsFidddle работает, но не [веб-страница] (http://webyo.com.au/contact-us.html) – Tate

ответ

0

Если вы проверите консоль, вы увидите сообщение об ошибке:

Uncaught TypeError: $(...).sticky is not a function

, что блок ошибки выполнение других сценариев и проверка тоже.

0

Ваша проблема в другом фрагменте кода:

$(document).ready(function(){ 
    $('#links').ReSmenu({ 
    maxWidth: 750 
    }); 
    $("#header2").sticky({ //<--- here is the error thrown 
    className: 'stuck' 
    }); 
}); 

в консоли (F12) вы можете увидеть сообщение об ошибке:

Uncaught TypeError: $(...).sticky is not a function

Смежные вопросы