本文實例講述了jQuery實作動態表單驗證時文字方塊抖動效果。分享給大家供大家參考。具體如下:
這裡使用jQuery實現的動態表單驗證特效,當用戶輸入錯誤或沒有輸入的時候點擊提交按鈕,有問題的輸入框會抖動幾下,以提示用戶此項有問題,文本框抖動功能都有意思,這個表單比較典型,想實作jquery Ajax表單功能的可以參考。
運作效果截圖如下:
線上示範網址如下:
http://demo.jb51.net/js/2015/jquery-table-txt-check-shake-style-codes/
具體程式碼如下:
<!DOCTYPE html> <head> <title>jQuery动态表单验证效果</title> <style type="text/css"> body { font-family:Arial, Sans-Serif; font-size:0.85em; } img { border:none; } ul, ul li { list-style-type: none; margin: 0; padding: 0; } ul li.first { border-top: 1px solid #DFDFDF; } ul li.last { border: none; } ul p { float: left; margin: 0; width: 310px; } ul h3 { float: left; font-size: 14px; font-weight: bold; margin: 5px 0 0 0; width: 200px; margin-left:20px; } ul li { border-bottom: 1px solid #DFDFDF; padding: 15px 0; width:600px; overflow:hidden; } ul input[type="text"], ul input[type="password"] { width:300px; padding:5px; position:relative; border:solid 1px #666; -moz-border-radius:5px; -webkit-border-radius:5px; } ul input.required { border: solid 1px #f00; } </style> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("#signup").click(function() { resetFields(); var emptyfields = $("input[value=]"); if (emptyfields.size() > 0) { emptyfields.each(function() { $(this).stop() .animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100) .animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100) .animate({ left: "0px" }, 100) .addClass("required"); }); } }); }); function resetFields() { $("input[type=text], input[type=password]").removeClass("required"); } </script> </head> <body> <ul> <li class="first"> <h3 id="您的名字">您的名字:</h3> <p><input type="text" value="First and Last name" id="name" name="name" /></p> </li> <li> <h3 id="Email地址">Email地址:</h3> <p><input type="text" value="my@email.com" name="email" /></p> </li> <li> <h3 id="密码">密码:</h3> <p><input type="password" name="passwd" /></p> </li> <li> <h3 id="密码确认">密码确认:</h3> <p><input type="password" name="passwd_conf" /></p> </li> <li> <h3 id="用户名">用户名:</h3> <p><input type="text" value="MyUserName" id="userName" name="user_name" /></p> </li> <li class="last"> <a id="signup" href="#"><img src="/static/imghwm/default1.png" data-src="images/buttonsubmit.png" class="lazy" style="max-width:90%" / alt="jQuery實作動態表單驗證時文字方塊抖動效果完整實例_jquery" ></a><img src="/static/imghwm/default1.png" data-src="images/clickhere.png" class="lazy" style="max-width:90%" / alt="jQuery實作動態表單驗證時文字方塊抖動效果完整實例_jquery" > </li> </ul> </body> </html>
希望本文所述對大家的jquery程式設計有所幫助。

javaandjavascriptaredistinctlanguages:javaisusedforenterpriseandmobileapps,while javascriptifforInteractiveWebpages.1)JavaisComcompoppored,statieldinglationallyTypted,statilly tater astrunsonjvm.2)

JavaScript核心數據類型在瀏覽器和Node.js中一致,但處理方式和額外類型有所不同。 1)全局對像在瀏覽器中為window,在Node.js中為global。 2)Node.js獨有Buffer對象,用於處理二進制數據。 3)性能和時間處理在兩者間也有差異,需根據環境調整代碼。

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

Python和JavaScript的主要區別在於類型系統和應用場景。 1.Python使用動態類型,適合科學計算和數據分析。 2.JavaScript採用弱類型,廣泛用於前端和全棧開發。兩者在異步編程和性能優化上各有優勢,選擇時應根據項目需求決定。

選擇Python還是JavaScript取決於項目類型:1)數據科學和自動化任務選擇Python;2)前端和全棧開發選擇JavaScript。 Python因其在數據處理和自動化方面的強大庫而備受青睞,而JavaScript則因其在網頁交互和全棧開發中的優勢而不可或缺。

Python和JavaScript各有優勢,選擇取決於項目需求和個人偏好。 1.Python易學,語法簡潔,適用於數據科學和後端開發,但執行速度較慢。 2.JavaScript在前端開發中無處不在,異步編程能力強,Node.js使其適用於全棧開發,但語法可能複雜且易出錯。

javascriptisnotbuiltoncorc; sanInterpretedlanguagethatrunsonenginesoftenwritteninc.1)JavascriptwasdesignedAsignedAsalightWeight,drackendedlanguageforwebbrowsers.2)Enginesevolvedfromsimpleterterpretpretpretpretpreterterpretpretpretpretpretpretpretpretpretcompilerers,典型地,替代品。

JavaScript可用於前端和後端開發。前端通過DOM操作增強用戶體驗,後端通過Node.js處理服務器任務。 1.前端示例:改變網頁文本內容。 2.後端示例:創建Node.js服務器。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

記事本++7.3.1
好用且免費的程式碼編輯器

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。