views:

302

answers:

3
<script type="text/javascript">
<!--
$(document).ready(function() { 
      $("#form1").validate({ 
        rules: { 
         budget: {
            required: true,
             minlength:3
        } ,
       duration: {
            required: true,
            digits:true
        }, 
         town: {
            required: true,
             minlength:2

        },

       content: {
            required: true,
            minlength:300 

        }
         }, 
        messages: { 


        } 
          }); 
        });
        -->
</script>

Two jquery files are included.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="../common/jquery.validate.js"></script>

are included. There is nothing wrong with the inclusion.

I got an error message

$("#form1").validate is not a function What's wrong?

A: 

Make sure that jQuery is using the $ variable, and its not another javascript framework.

Check your doctype: Validate your html, sometimes browsers don't see stuff in quirks mode, or when they encouter malformed html.

Also ensure that jquery.validate.js file is correct.

You can download it below:

http://bassistance.de/jquery-plugins/jquery-plugin-validation/

CodeJoust
How to ensure that jquery.validate.js file is correct? I think it is correct.
Steven
A: 

If you had a link I could look to see what the issue is but here are a couple questions and things to check:

  • Is the ID for your form named "form" in the HTML?
  • Check to see if messages are required, maybe there is some imbalance in parameters
  • You should also add the 'type="text/javascript"' attributes where you are getting jQuery from Google

Also, if you're going to use the Google CDN for getting jQuery you may as well use Microsoft's CDN for getting your validation file. Any of these URLs will work:

Liam
I have tried the URLs you provided, but the problem still can not be eliminated.
Steven
A: 

Maybe silly, but check that you inline script is AFTER you include the script tags.

fredrik
Yes, Jquery code is after my include the script tags.
Steven
If you use Firbug: test to write $.fn.validate in the console and see if it's declared.Are you using any other js-librarys in the same solution?
fredrik