easyui validatebox验证
生活随笔
收集整理的這篇文章主要介紹了
easyui validatebox验证
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
<html?xmlns="http://www.w3.org/1999/xhtml"> <head><script?src="easyui1.2.4/jquery-1.6.min.js"?type="text/javascript"></script><script?src="easyui1.2.4/jquery.easyui.min.js"?type="text/javascript"></script><!--自定義驗(yàn)證--><script?src="easyui1.2.4/validator.js"?type="text/javascript"></script><link?href="easyui1.2.4/themes/default/easyui.css"?rel="stylesheet"?type="text/css"?/><script>$(function?()?{//設(shè)置text需要驗(yàn)證$('input[type=text]').validatebox();})</script> </head> <body>郵箱驗(yàn)證:<input?type="text"?validtype="email"?required="true"?missingMessage="不能為空"?invalidMessage="郵箱格式不正確"?/><br?/>網(wǎng)址驗(yàn)證:<input?type="text"?validtype="url"?invalidMessage="url格式不正確[http://www.example.com]"?/><br?/>長(zhǎng)度驗(yàn)證:<input?type="text"?validtype="length[8,20]"?invalidMessage="有效長(zhǎng)度8-20"?/><br?/>手機(jī)驗(yàn)證:<input?type="text"?validtype="mobile"??/><br?/>郵編驗(yàn)證:<input?type="text"?validtype="zipcode"?/><br?/>賬號(hào)驗(yàn)證:<input?type="text"?validtype="account[8,20]"?/><br?/>漢字驗(yàn)證:<input?type="text"?validtype="CHS"?/><br?/>遠(yuǎn)程驗(yàn)證:<input?type="text"?validtype="remote['checkname.aspx','name']"?invalidMessage="用戶(hù)名已存在"/> </body> </html> //自定義validator.js //擴(kuò)展easyui表單的驗(yàn)證 $.extend($.fn.validatebox.defaults.rules,?{//驗(yàn)證漢字CHS:?{validator:?function?(value)?{return?/^[\u0391-\uFFE5]+$/.test(value);},message:?'只能輸入漢字'},//移動(dòng)手機(jī)號(hào)碼驗(yàn)證mobile:?{//value值為文本框中的值validator:?function?(value)?{var?reg?=?/^1[3|4|5|8|9]\d{9}$/;return?reg.test(value);},message:?'輸入手機(jī)號(hào)碼格式不準(zhǔn)確.'},//國(guó)內(nèi)郵編驗(yàn)證zipcode:?{validator:?function?(value)?{var?reg?=?/^[1-9]\d{5}$/;return?reg.test(value);},message:?'郵編必須是非0開(kāi)始的6位數(shù)字.'},//用戶(hù)賬號(hào)驗(yàn)證(只能包括?_?數(shù)字?字母)?account:?{//param的值為[]中值validator:?function?(value,?param)?{if?(value.length?<?param[0]?||?value.length?>?param[1])?{$.fn.validatebox.defaults.rules.account.message?=?'用戶(hù)名長(zhǎng)度必須在'?+?param[0]?+?'至'?+?param[1]?+?'范圍';return?false;}?else?{if?(!/^[\w]+$/.test(value))?{$.fn.validatebox.defaults.rules.account.message?=?'用戶(hù)名只能數(shù)字、字母、下劃線組成.';return?false;}?else?{return?true;}}},?message:?''} })轉(zhuǎn)載于:https://my.oschina.net/shuming/blog/667914
與50位技術(shù)專(zhuān)家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的easyui validatebox验证的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 阿里巴巴集团CRO刘振飞:双11的六维技
- 下一篇: 服务器搭建:3.1、openresty图