日期:2014-05-16  浏览次数:20334 次

jquery.form.js应用入门

下面介绍Jquery框架的表单验证插件jquery.form.js的应用,首先下载必需的JS文件
jquery.form.rar
jquery.rar
下面开始使用:
Form插件的简单入门

第一步:先增加一个表

form id="myForm" action="comment.php" method="post">
     Name: <input type="text" name="name" />
     Comment: <textarea name="comment"></textarea>
     <input type="submit" value="Submit Comment" />
</form>

?

?

第二步:jquery.js和form.js文件的包含

<head>
     <script type="text/javascript" src="path/to/jquery.js"></script>
     <script type="text/javascript" src="path/to/form.js"></script>
      <script type="text/javascript">
         // wait for the DOM to be loaded
          $(document).ready(function() {
             // bind 'myForm' and provide a simple callback function
          $('#myForm').ajaxForm(function() {
                 alert("Thank you for your comment!");
             });
         });
     </script>
</head

?

?

该插件的作者在介绍form.js时,说了这样的一句话:

Submitting a form with AJAX doesn't get any easier than this!
?