ip138에서 각종 클라이언트 검증 js 코드

3854 단어
 
  
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 ");
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(" 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(" “0” 3-7 ");
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(" ");
document.area2zipForm.area.focus();
return false;
}
if(sArea.length<2){
alert(" 2 ");
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(" ");
document.area2zoneForm.area.focus();
return false;
}
if(sArea.length<2){
alert(" 2 ");
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(" 15 18 ");
document.IDform.userid.focus();
return false;
}
}
//-->

좋은 웹페이지 즐겨찾기