자바스크립트2011. 1. 10. 12:46
/**
*** 해당 라디오 객체에 인자로 넘어온 값이 체크되었는지
*** 확인한다.
*/
function returnCheckValue(field, val){
        for(i=0; i < field.length; i++ ){
            if(field[i].value == val && field[i].checked){
                return true;
            }
        }
        return false;
 }
/**
*** 사업자번호 체크
**/
function chkBusinessNo(){
    var chkRule = "137137135";
    var strCoreNum = document.myform.business_no1.value 
                              + document.myform.business_no2.value 
                              + document.myform.business_no3.value;
    var step1, step2, step3, step4, step5, step6, step7;
	
    step1 = 0;
    for(i=0; i<7;i++)
        step1 = step1 + (strCoreNum.substring(i, i+1)* chkRule.substring(i, i+1));
		
    step2 = step1 % 10;
    step3 = (strCoreNum.substring(7,8) * chkRule.substring(7,8)) % 10;
    step4 = strCoreNum.substring(8,9) * chkRule.substring(8,9);
	
    step5 = Math.round(step4 / 10 - 0.5);
    step6 = step4 - (step5 * 10);

    step7 = (10 - ((step2 + step3 + step5 + step6) % 10)) % 10;

    if(strCoreNum.substring(9,10) != step7){
        alert('올바른 사업자등록번호가 아닙니다. 다시 확인해주세요');
        return false;
    }
    return true;
}
Posted by 베니94