Validform+layer實(shí)現(xiàn)漂亮的表單驗(yàn)證特效
Validform是一款優(yōu)秀的表單驗(yàn)證插件,layer是一款優(yōu)秀的彈出窗口插件。下面通過例子看看這二者碰出的火花吧
首先要引入jquery,Validform和layer
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="http://res.layui.com/lay/lib/layer/src/layer.js"></script> <script type="text/javascript" src="http://lib.h-ui.net/Validform/5.3.2/Validform.min.js"></script>
HTML
<form action="post.php" method="post" name="form" class="form form-horizontal" id="form-Validform"> <div class="row cl"> <label class="form-label col-3"><span class="c-red">*</span>用戶昵稱:</label> <div class="formControls col-8"> <input type="text" class="input-text" value="" placeholder="可使用3-16位中英文字符" id="uname" name="uname" datatype="*2-16" nullmsg="用戶昵稱不能為空"> </div> </div> <div class="row cl"> <label class="form-label col-3"><span class="c-red">*</span>用戶密碼:</label> <div class="formControls col-8"> <input type="text" class="input-text" value="" placeholder="5-20位,范圍[0-9a-zA-Z_@!.-]" id="pwd" name="pwd" datatype="/\w{5,20}/i" nullmsg="用戶密碼不能為空"> </div> </div> <div class="row cl"> <label class="form-label col-3"><span class="c-red">*</span>Email:</label> <div class="formControls col-8"> <input type="text" class="input-text" value="" placeholder="****@***.***" id="email" name="email" datatype="e" nullmsg="Email不能為空"> </div> </div> <div class="row cl"> <label class="form-label col-3"></label> <div class="formControls col-8"> <a href="javascript:;" id="safecodes" style="color:red"><?php echo $safecode; ?></a> </div> </div> </div> <div class="row cl" style="text-align:center"> <input class="btn btn-primary radius" type="submit" value=" 提交 "> </div> </form>
JS
<script type="text/javascript"> $(function(){ $("#form-Validform").Validform({ tiptype:4, ajaxPost:true, callback:function(data){ if(data.status==1){ layer.msg(data.info, {icon: data.status,time: 1000}, function(){ location.reload();//刷新頁面 }); } else{ layer.msg(data.info, {icon: data.status,time: 3000}); } } }); $('#safecodes').click( function () { $('#safecode').val($('#safecodes').text()); }); }); </script>
服務(wù)端返回
{"info":"\u6210\u529f","status":1,"url":""}
本例子流程:點(diǎn)擊提交->逐項(xiàng)驗(yàn)證表單->完成驗(yàn)證ajax提交->根據(jù)返回信息判斷->彈出消息
相關(guān)文章
jQuery Easyui Tabs擴(kuò)展根據(jù)自定義屬性打開頁簽
這篇文章主要介紹了jQuery Easyui Tabs擴(kuò)展根據(jù)自定義屬性打開頁簽的實(shí)現(xiàn)代碼,首先增加擴(kuò)展,接著點(diǎn)擊事件open方法實(shí)現(xiàn)easyui tabs擴(kuò)展,非常不錯,需要的朋友可以參考下2016-08-08jQuery實(shí)現(xiàn)每隔一段時(shí)間自動更換樣式的方法分析
這篇文章主要介紹了jQuery實(shí)現(xiàn)每隔一段時(shí)間自動更換樣式的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了jQuery結(jié)合時(shí)間函數(shù)動態(tài)修改頁面元素屬性相關(guān)操作技巧,需要的朋友可以參考下2018-05-05jQuery學(xué)習(xí)之DOM節(jié)點(diǎn)的插入方法總結(jié)
這篇文章主要給大家介紹了jQuery中DOM節(jié)點(diǎn)的插入方法,文章總結(jié)的很全面,相信對大家具有一定的參考價(jià)值,需要的朋友們一起來看看吧。2017-01-01基于jquery的當(dāng)鼠標(biāo)滾輪到最底端繼續(xù)加載新數(shù)據(jù)思路分享(多用于微博、空間、論壇 )
基于jquery的當(dāng)鼠標(biāo)滾輪到最底端繼續(xù)加載新數(shù)據(jù)思路分享(多用于微博、空間、論壇 ),需要的朋友可以參考下。2011-10-10jQuery 實(shí)現(xiàn)圖片的依次加載圖片功能
本文分為css和js代碼兩部分給大家詳細(xì)介紹了jQuery 實(shí)現(xiàn)圖片的依次加載圖片功能,非常不錯,具有參考借鑒價(jià)值,需要的的朋友參考下吧2017-07-07jQuery實(shí)現(xiàn)的網(wǎng)站banner圖片無縫輪播效果完整實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的網(wǎng)站banner圖片無縫輪播效果,結(jié)合完整實(shí)例形式分析了jQuery結(jié)合時(shí)間函數(shù)實(shí)現(xiàn)圖片定時(shí)輪播切換相關(guān)操作技巧,需要的朋友可以參考下2019-01-01