Posted
Filed under Htm&Javascript

//숫자체크  
function checkNum(obj){
     if (obj == null || isNaN(obj.value)){
     obj.focus();
     return false;
    }   
    return true;
   }

  //핸드폰 체크
function hpCheck(obj1,obj2,obj3){
    var hp1 = obj1.value.replace(' ','');
    var hp2 = obj2.value.replace(' ','');
    var hp3 = obj3.value.replace(' ','');
    
    var arr_hp2 = new Array(hp2.length);
    var arr_hp3 = new Array(hp3.length);
    var i=0;
    for (i=0;i<hp2.length;i++){
     arr_hp2[i] = hp2.charAt(i);
    }
    for (i=0;i<hp3.length;i++){
     arr_hp3[i] = hp3.charAt(i);
    }    
 
    if (!checkNum(obj2))
     return false;

    if (hp2.length <=2)
     return false;
 
    if (!checkNum(obj3))
     return false;  
    if (hp3.length !=4)
     return false;      
    

    if (hp1 == '010')
    {
     if (hp2.length == 4)
      return true;
     else
      return false;
    }else if (hp1 == '011' || hp1 == '016' || hp1 == '017' || hp1 == '018' || hp1 == '019'){
     if (arr_hp2[0] == '1' || arr_hp2[0]=='9')
     {
      if (hp2.length == 4)
       return true;
      else
       return false;
     }else if (arr_hp2[0] == '0'){
      return false;
     }else{
       if (hp2.length == 3)
       return true;
      else
       return false;     
     }
    }
    return true;
   }


2011/06/12 14:32 2011/06/12 14:32