手機端表單驗證外掛程式

來源:互聯網
上載者:User

標籤:this   int   函數   for   手機   lock   auto   cti   username   

html結構

<form id="myform">
<p><label>手機號</label><input name="user_phone" type="text" placeholder="請輸入您的手機號碼" data-pattern="^0?1[3|4|5|8][0-9]\d{8}$" data-required="true" data-descriptions="userphone" data-describedby="userphone-description"/></p>
<p><label>姓名</label><input name="user_name" type="text" placeholder="請填寫您的姓名" data-required="true" data-descriptions="username" data-describedby="username-description"></p>
<p><label>職位</label><input name="position_name" type="text" placeholder="請填寫您的職位" data-required="true" data-descriptions="positionname" data-describedby="positionname-description"></p>
<p><label>股票代號</label><input name="stock_code" type="text" placeholder="請填寫您公司的股票代號" data-required="true" data-descriptions="stockcode" data-describedby="stockcode-description"/></p>
<p><label>公司名稱</label><input name="company_name" type="text" placeholder="請填寫您公司的名稱" data-required="true" data-descriptions="companyname" data-describedby="companyname-description"/></p>
</form>

css部分
.field-invalid{
border-color:#a94442;
}
.field-invalidmsg{
color:#a94442;
}
.field-validmsg{
color:#3c763d;
}
.field-tooltipWrap{
position: absolute;
left: 0;
top: 0;
width: 100%;
z-index: 19891014;
}
.field-tooltipInner{
pointer-events: none;
display: table;
position:fixed;
left:0;
top:0;
width:100%;
height:100%;
}
.field-tooltip{
display: table-cell;
vertical-align: middle;
text-align: center;
}
.field-tooltip .field-invalidmsg,
.field-tooltip .field-validmsg{
color: #fff;
}
.field-tooltip .zvalid-resultformat{
display: inline-block;
position: relative;
font-weight:bold;">rgba(0,0,0,0.8);
color: #fff;
padding: 10px 15px;
font-size: 14px;
border-radius: 6px;
box-shadow: 0 0 8px rgba(0,0,0,.1);
pointer-events: auto;
animation-name:fieldTipBounceIn;
-webkit-animation-name:fieldTipBounceIn;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-duration: .18s;
animation-duration: .18s;
}

@-webkit-keyframes fieldTipBounceIn{

0% {
opacity: 0;
-webkit-transform: scale3d(.3, .3, .3);
transform: scale3d(.3, .3, .3);
}
100% {
opacity: 1;
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1);
}
}


@keyframes fieldTipBounceIn
{


0% {
opacity: 0;
-webkit-transform: scale3d(.3, .3, .3);
transform: scale3d(.3, .3, .3);
}
100% {
opacity: 1;
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1);
}
}



js部分
//表單驗證
$("#myform").mvalidate({
type:1,
onKeyup:true,
sendForm:true,
firstInvalidFocus:false,
valid:function(event,options){
//點擊提交按鈕時,表單通過驗證觸發函數
//alert("驗證通過!接下來可以做你想做的事情啦!");
alert(‘通過了驗證‘);
event.preventDefault();
},
invalid:function(event, status, options){
//點擊提交按鈕時,表單未通過驗證觸發函數
// alert("表單未通過驗證!");

},
eachField:function(event,status,options){
//點擊提交按鈕時,表單每個輸入欄位觸發這個函數 this 執向當前表單輸入欄位,是jquery對象
// alert("每個都彈出!");
},
eachValidField:function(val){},
eachInvalidField:function(event, status, options){},
conditional:{
},
descriptions:{
username:{
required : ‘請輸入姓名‘
},
userphone : {
required : ‘請輸入手機號碼‘,
pattern : ‘手機號格式不正確‘
},
stockcode : {
required : ‘請輸入股票代號‘
},
positionname : {
required : ‘請輸入您的職位‘
},
companyname : {
required : ‘請輸入公司名稱‘
}

}
});


下載外掛程式
jquery-mvalidate.js
mvalidate.css

手機端表單驗證外掛程式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.