0

I am using wordpress. In wordpress I want to live validate a form. So after searching different jQuery form validation I got http://www.geektantra.com/projects/jquery-form-validate/ link. I used all the source codes in my site. But after all that when I rendered the page I got this errors in my chrome console tab

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

all of my jquery files are included in header file like this

<?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');
?>

and the jQuery code inside head is like this

<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>

Can someone kindly help me how to solve this. It will be really appreciable.

4

1 回答 1

0

通过查看您的错误代码,我认为可能存在一些问题,例如

  • jQuery 未在您的站点中正确加载

  • jQuery 框架在您的 jQuery 插件之后加载

因此,要检查它们,只需通过页面源代码,即ctrl+u在您的键盘中检查每个文件是否与其外部文件正确链接。应该检查一个主要的事情是检查 jQuery 是第一次加载,然后是在你的 jQuery 插件加载之后。

希望这些步骤将帮助您检查错误。

于 2012-12-29T10:50:34.377 回答