jQuery form 表單驗證外掛程式(fieldValue)校正表單,jqueryfieldvalue

來源:互聯網
上載者:User

jQuery form 表單驗證外掛程式(fieldValue)校正表單,jqueryfieldvalue

jQuery form表單驗證相關知識,在做項目中經常會用到,其實也不算複雜,下面通過一段代碼給大家介紹jQuery form 表單驗證外掛程式(fieldValue)校正表單的相關知識,感興趣的朋友一起學習吧

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>jQuery form外掛程式的使用--使用 fieldValue 方法校正表單.</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><script src="jquery-1.3.1.js" type="text/javascript"></script><script src="jquery.form.js" type="text/javascript"></script><script type="text/javascript"> $(document).ready(function() { $('#myForm').ajaxForm({ target: '#output1', // 用伺服器返回的資料 更新 id為output1的內容.beforeSubmit: validate // 提交前,驗證}); });function validate(formData, jqForm, options) { // fieldValue 是表單外掛程式的一個方法,它能找出表單中的元素的值,返回一個集合。var usernameValue = $('input[name=name]').fieldValue(); var addressValue = $('input[name=address]').fieldValue(); if (!usernameValue[0] || !addressValue[0]) { alert('使用者名稱和地址不可為空,自我介紹可以為空白!'); return false; } var queryString = $.param(formData); //組裝資料//alert(queryString); //類似 : name=1&add=2 return true; }</script> </head><body><h3> Demo 7 : jQuery form外掛程式的使用--使用 fieldValue 方法校正表單. </h3><!-- demo1 --><form id="myForm" action="ajax2.jsp" method="post"> 名稱: <input type="text" name="name" id="name" /> <br/>地址: <input type="text" name="address" id="address"/><br/> 自我介紹: <textarea name="comment" id="comment" ></textarea> <br/><input type="submit" id="test" value="提交" /> <br/><div id="output1" ></div></form></body></html>

以上所述是針對jQuery form 表單驗證外掛程式(fieldValue)校正表單的相關內容,希望大家喜歡。

您可能感興趣的文章:
  • jQuery formValidator表單驗證外掛程式開源了 含API協助、源碼、樣本
  • jQuery 表單驗證外掛程式formValidation實現個人化錯誤提示
  • jQuery表單驗證外掛程式formValidator(改進版)
  • jquery表單驗證使用外掛程式formValidator
  • 基於Bootstrap+jQuery.validate實現Form表單驗證
  • jQuery formValidator表單驗證

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.