分享純手寫(xiě)漂亮的表單驗(yàn)證
哈哈 手工饅頭好吃,今天小編跟大家分享手工js表單驗(yàn)證代碼,感興趣的朋友快來(lái)吧。
因?yàn)槭亲远x樣式,所以兼容所有瀏覽器版本,個(gè)人認(rèn)為非常漂亮:網(wǎng)址wuxi.rongzi.com
css
<style> /*tooltip*//* CSS屬性順序按照 字母首字母 排列*/ .ui-slider-tooltip{ background:#fa; border:px solid #fa; color:#fff; display: block; text-align: left; padding: px px px px; position: absolute; z-index:; } .ui-corner-all { border-radius: px; -moz-border-radius-bottomleft:px; -moz-border-radius-bottomright:px; -moz-border-radius-topleft:px; -moz-border-radius-topright:px; -webkit-border-top-left-radius:px px; -webkit-border-top-right-radius:px px;-webkit-border-bottom-right-radius:px px; -webkit-border-bottom-left-radius:px px;} .ui-tooltip-pointer-down { border-bottom-width: ; border-left: px dashed transparent; border-right: px dashed transparent; border-top: px solid #fa; bottom: -px; display: block; height:; left: %; margin-left: -px; position: absolute; width:;} .ui-tooltip-pointer-down-inner { border-left: px dashed transparent; border-right: px dashed transparent; border-top: px solid #fa; left: -px; top: -px; position: absolute; } .tip{ font-size:pt; line-height:px;} .error{ border: px solid rgb(, , );} </style>
前臺(tái):
<input type="text" id="userName"/> <input type="submit" onclick="submitOneClickApply()"/>
js:
function submitOneClickApply() { var username = $("#userName").val(); if (username == "" || username == "請(qǐng)輸入您的姓名") { $("#userName").rzAlertTips({ flagInfo: '請(qǐng)輸入聯(lián)系人', isAnimate: true }); }
調(diào)用的js:
<script type="text/javascript"> (function ($) { jQuery.fn.extend({ rzAlertTips: function (settings) { $(this).each(function () { //初始化配置信息 var options = jQuery.extend({ flagCss: "tip", flagWidth: $(this).outerWidth(), flagInfo: $(this).attr("title"), isAnimate: false }, settings); if (!options.flagInfo) { return; } $(this).removeAttr("title"); var obj = $(this); var oToolTip = null; var fun_show = function () { //設(shè)置提示信息最小寬度為 options.flagWidth = "auto"; // (parseInt(options.flagWidth) < ) ? : parseInt(options.flagWidth);+ "px" var oTip = $("<div class='ui-slider-tooltip ui-corner-all' id='tipWrap_" + $(this).attr("id") + "'></div>"); var oPointer = $("<div class='ui-tooltip-pointer-down'><div class='ui-tooltip-pointer-down-inner'></div></div>"); var oTipInfo = $("<div>" + options.flagInfo + "</div>").attr("class", options.flagCss).css("width", options.flagWidth); //合并提示信息 oToolTip = $(oTip).append(oTipInfo).append(oPointer); if ($("#tipWrap_" + $(this).attr("id")).length > ) $("#tipWrap_" + $(this).attr("id")).remove(); //添加淡入效果 if (options.isAnimate) { $(oToolTip).fadeIn("slow"); } $(obj).after(oToolTip); //計(jì)算提示信息的top、left和width //position.top var position = $(obj).position(); var oTipTop = eval(position.top - $(oTip).outerHeight() - ); var oTipLeft = position.left; $(oToolTip).css("top", oTipTop + "px").css("left", oTipLeft + "px"); }; fun_show(); $('.error').removeClass('error'); $(this).addClass("error"); setTimeout(function () { $(oToolTip).remove(); }, ); }); return this; } })(jQuery); </script>
以上內(nèi)容就是小編給大家分享的純手寫(xiě)漂亮的表單驗(yàn)證,希望大家喜歡。
相關(guān)文章
基于javascript實(shí)現(xiàn)最簡(jiǎn)單的選項(xiàng)卡切換效果
這篇文章主要介紹了基于javascript實(shí)現(xiàn)最簡(jiǎn)單的選項(xiàng)卡切換效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05JS實(shí)現(xiàn)加載和讀取XML文件的方法詳解
這篇文章主要介紹了JS實(shí)現(xiàn)加載和讀取XML文件的方法,結(jié)合實(shí)例形式分析了javascript針對(duì)xml文件的加載與讀取相關(guān)實(shí)現(xiàn)步驟與操作技巧,需要的朋友可以參考下2017-04-04利用window.name實(shí)現(xiàn)windowStorage代碼分享
本文主要介紹了利用window.name實(shí)現(xiàn)windowStorage的功能分享,大家參考使用吧2014-01-01JS模擬實(shí)現(xiàn)京東快遞單號(hào)查詢
這篇文章主要為大家詳細(xì)介紹了JS模擬實(shí)現(xiàn)京東快遞單號(hào)查詢,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11dess中一個(gè)簡(jiǎn)單的多路委托的實(shí)現(xiàn)
這個(gè)SDelegate用起來(lái)可能會(huì)比較詭異,比如很多操作都要重新賦值。Dess中,SDelegate主要用于一些特定場(chǎng)合,如DOM事件派發(fā)。2010-07-07