ip138中各種客戶(hù)端驗(yàn)證js代碼
更新時(shí)間:2009年12月09日 02:58:01 作者:
包括ip驗(yàn)證,身份證驗(yàn)證,手機(jī)號(hào)碼驗(yàn)證,電話(huà)號(hào)碼,郵政編碼驗(yàn)證,域名驗(yàn)證等,其實(shí)好的代碼,都在應(yīng)用中,大家多去扒代碼吧。
復(fù)制代碼 代碼如下:
function checkIP()
{
var ipArray,ip,j;
ip = document.ipform.ip.value;
if(/[A-Za-z_-]/.test(ip)){
if (ip.indexOf(" ")>=0){
ip = ip.replace(/ /g,"");
document.ipform.ip.value = ip;
}
if (ip.toLowerCase().indexOf("http://")==0){
ip = ip.slice(7);
document.ipform.ip.value = ip;
}
if(!/^([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)|(io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))$/.test(ip)){
alert("不是正確的域名");
document.ipform.ip.focus();
return false;
}
}
else{
ipArray = ip.split(".");
j = ipArray.length
if(j!=4)
{
alert("不是正確的IP");
document.ipform.ip.focus();
return false;
}
for(var i=0;i<4;i++)
{
if(ipArray[i].length==0 || ipArray[i]>255)
{
alert("不是正確的IP");
document.ipform.ip.focus();
return false;
}
}
}
}
function checkMobile(){
var sMobile = document.mobileform.mobile.value
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(sMobile))){
alert("不是完整的11位手機(jī)號(hào)或者正確的手機(jī)號(hào)前七位");
document.mobileform.mobile.focus();
return false;
}
window.open('', 'mobilewindow', 'height=197,width=350,status=yes,toolbar=no,menubar=no,location=no')
}
function checkZip(){
var sZip = document.zipform.zip.value
if(!(/^\d{4,6}$/.test(sZip))){
alert("請(qǐng)輸入郵政編碼前4-6位");
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}
function checkZone(){
var sZone = document.zoneform.zone.value
if(!(/^0\d{2,6}$/.test(sZone))){
alert("請(qǐng)輸入以“0”開(kāi)頭的3-7位區(qū)號(hào)");
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}
function checkArea2Zip(){
var sArea = document.area2zipForm.area.value
if(sArea==""){
alert("請(qǐng)輸入地址");
document.area2zipForm.area.focus();
return false;
}
if(sArea.length<2){
alert("地址至少要有2個(gè)字");
document.area2zipForm.area.focus();
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}
function checkArea2Zone(){
var sArea = document.area2zoneForm.area.value
if(sArea==""){
alert("請(qǐng)輸入地址");
document.area2zoneForm.area.focus();
return false;
}
if(sArea.length<2){
alert("地址至少要有2個(gè)字");
document.area2zoneForm.area.focus();
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}
function checkID(){
var sID = document.IDform.userid.value
if(!(/^\d{15}$|^\d{18}$|^\d{17}[xX]$/.test(sID))){
alert("請(qǐng)輸入15位或18位身份證號(hào)");
document.IDform.userid.focus();
return false;
}
}
//-->
</script>
您可能感興趣的文章:
- js在客戶(hù)端驗(yàn)證密碼強(qiáng)度,兼容FireFox和IE
- javascript 客戶(hù)端驗(yàn)證上傳圖片的大?。嫒軮E和火狐)
- jquery 表單進(jìn)行客戶(hù)端驗(yàn)證demo
- fileupload控件 文件類(lèi)型客戶(hù)端驗(yàn)證實(shí)現(xiàn)代碼
- JAVASCRIPT 客戶(hù)端驗(yàn)證數(shù)據(jù)的合法性代碼(正則)
- 使用jQuery.Validate進(jìn)行客戶(hù)端驗(yàn)證(初級(jí)篇) 不使用微軟驗(yàn)證控件的理由
- JavaScript通過(guò)RegExp實(shí)現(xiàn)客戶(hù)端驗(yàn)證處理程序
- php實(shí)現(xiàn)的數(shù)字驗(yàn)證碼及數(shù)字運(yùn)算驗(yàn)證碼
- js代碼驗(yàn)證手機(jī)號(hào)碼和電話(huà)號(hào)碼是否合法
- 詳解ASP.NET七大身份驗(yàn)證方式以及解決方案
- ASP.NET中驗(yàn)證控件的使用方法
- Asp.Mvc?2.0實(shí)現(xiàn)用戶(hù)注冊(cè)實(shí)例講解(1)
- ASP.NET驗(yàn)證碼(3種)
- javascript表單驗(yàn)證大全
- Asp.Mvc?2.0用戶(hù)客戶(hù)端驗(yàn)證實(shí)例講解(3)
相關(guān)文章
javascript高級(jí)程序設(shè)計(jì)(第三版)學(xué)習(xí)筆記(一) 正則表達(dá)式整理
javascript高級(jí)程序設(shè)計(jì) 正則表達(dá)式整理,想學(xué)習(xí)js正則表達(dá)式的朋友可以參考下2012-08-08正則表達(dá)式實(shí)現(xiàn)將MM/DD/YYYY格式的日期轉(zhuǎn)換為YYYY-MM-DD格式
這篇文章主要介紹了正則表達(dá)式實(shí)現(xiàn)將MM/DD/YYYY格式的日期轉(zhuǎn)換為YYYY-MM-DD格式的方法,是一個(gè)比較簡(jiǎn)單實(shí)用的正則替換應(yīng)用,對(duì)于怎能則表達(dá)式的學(xué)習(xí)具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12asp 正則表達(dá)式檢測(cè)http開(kāi)頭的函數(shù)
asp 正則表達(dá)式檢測(cè)http開(kāi)頭的函數(shù)...2007-08-08積累比較常用的正則表達(dá)式(例如:匹配中文、匹配html)
本文是小編在日常工作中積累并整理的有關(guān)一些常用的正則表達(dá)式(例如:匹配中文、匹配html),在此把全部?jī)?nèi)容分享在腳本之家網(wǎng)站,需要的朋友可以來(lái)腳本之家網(wǎng)站學(xué)習(xí)2015-10-10JS正則表達(dá)式匹配檢測(cè)各種數(shù)值類(lèi)型(數(shù)字驗(yàn)證)
這篇文章主要介紹了JS正則表達(dá)式匹配檢測(cè)各種數(shù)值類(lèi)型(數(shù)字驗(yàn)證)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2016-08-08密碼強(qiáng)度的正則表達(dá)式兩種方案JS總結(jié)篇
本文給出了兩個(gè)密碼強(qiáng)度的正則表達(dá)式方案,一個(gè)簡(jiǎn)單,一個(gè)更復(fù)雜和安全。并分別給出了兩個(gè)方案的解析和測(cè)試程序。對(duì)密碼強(qiáng)度正則表達(dá)式的兩種方案感興趣的朋友跟隨腳本之家一起看看吧2018-03-03