0

私はワードプレスを使用しています。ワードプレスでは、フォームをライブ検証したいと思います。したがって、さまざまなjQueryフォーム検証を検索した後、 http://www.geektantra.com/projects/jquery-form-validate/リンクを取得しました。私は自分のサイトのすべてのソースコードを使用しました。しかし、その後、ページをレンダリングすると、Chromeコンソールタブでこのエラーが発生しました

Uncaught TypeError: Object [object Object] has no method 'validate' localhost:70
(anonymous function) localhost:70
o jquery.js:2
p.fireWith jquery.js:2
e.extend.ready jquery.js:2
c.addEventListener.B

私のjqueryファイルはすべてこのようなヘッダーファイルに含まれています

<?php
  wp_enqueue_script('jQuery', get_bloginfo('template_url').'/js/jquery-1.3.2.min.js');
  wp_enqueue_script('Validations', get_bloginfo('template_url').'/js/jquery.validate.js');
  wp_enqueue_script('Validations Function', get_bloginfo('template_url').'/js/jquery.validation.functions.js');
?>

頭の中のjQueryコードは次のようになります

<script type="text/javascript">
 jQuery(document).ready(function() {
    jQuery("#ValidTitle").validate({
        expression: "if (VAL != '0') return true; else return false;",
        message: "Please make a right selection for the title"
    });
    jQuery("#Name").validate({
        expression: "if (VAL) return true; else return false;",
        message: "Please enter your name"
    });
    jQuery("#BusinessPhone").validate({
        expression: "if (VAL.match(/^[9][0-9]{9}$/)) return true; else return false;",
        message: "Should be a valid Phone Number"
    });
    jQuery("#ValidEmail").validate({
        expression: "if (VAL.match(/^[^\\W][a-zA-Z0-9\\_\\-\\.]+([a-zA-Z0-9\\_\\-\\.]+)*\\@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*\\.[a-zA-Z]{2,4}$/)) return true; else return false;",
        message: "Please enter a valid Email ID"
    });
    jQuery("#NumberOfEmployee").validate({
        expression: "if (!isNaN(VAL) && VAL) return true; else return false;",
        message: "Please enter a valid number of employees"
    });
    jQuery("#ValueSoftware").validate({
        expression: "if (VAL != '0') return true; else return false;",
        message: "Please make a right selection for Value Software"
    });                
    jQuery("#TaxYear").validate({
        expression: "if (VAL != '0') return true; else return false;",
        message: "Please make a selection"
    });
});

</script>

誰かがこれを解決する方法を親切に助けてくれますか?それは本当に認められるでしょう。

4

1 に答える 1

0

あなたのエラーコードを調べることによって、私は次のようないくつかの問題があるかもしれないと思います

  • jQueryがサイトに正しく読み込まれていません

  • jQueryフレームワークはjQueryプラグインの後にロードされます

したがって、それらを確認するには、ページのソースコード、つまりctrl+uキーボードを調べて、すべてのファイルが外部ファイルに適切にリンクされているかどうかを確認してください。主なことの1つは、jQueryプラグインがロードされた後、jQueryが最初にロードされていることを確認することです。

これらの手順がエラーの確認に役立つことを願っています。

于 2012-12-29T10:50:34.377 に答える