jquery表单验证插件

时间:2012-12-31 23:16:47

标签: jquery jquery-validate

我正在使用jquery表单验证来验证我的表单,但是我收到以下错误:

         Uncaught ReferenceError: jQuery is not defined jquery.validate.js:1178
Uncaught TypeError: undefined is not a function bootstrap.js:29
Uncaught ReferenceError: $ is not defined mimi.html:20

这是我的代码:

<!DOCTYPE HTML>
<html>
 <head>
    <link type = "text/css" rel="stylesheet" href="css/bootstrap.css" />

       <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
       <script src="js/bootstrap.js"> </script>
       <script> 
                 $(function(){ 
                                 $('form').validate()
                             }); 
        </script> 
 </head>
 <body> 
 <form class = "well span6"> 

 <label> Username </label> 
 <input type="text" id = "myName" class ="span3" placeholder ="Type your username here..." class = "required"/> 

  <label> Password</label> 
 <input type="text" id "myPassword" class ="span3" placeholder ="Type your password here..." class = "required"/> <br/> 

 <button id = "submit" class ="btn btn-primary">Submit </button>
 <button class = "" > Clear <br/></button><br/> 
 </form> 



 </body> 

</html>

非常感谢你们的帮助。

1 个答案:

答案 0 :(得分:4)

jQuery Validate需要jQuery。您可以在jquery.validate.js脚本之前添加。

<script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js" type="text/javascript"></script>