function checkvalue() {
var r = document.register;
var total_value = 0;
total_value = r.price.value;
//--- replace는 한 개의 문자만 실행한다.
//--- 만약 , 가 두개가 있다면 두번을 실행해주어야한다.
total_value = total_value.replace(\',\',\'\');
total_value = total_value.replace(\',\',\'\');
total_value = total_value.replace(\',\',\'\');
// alert(total_value );
if (isNaN(total_value)) {
alert(\'숫자만 입력해 주십시오1.\');
//r.price.value = \"\";
r.price.focus();
}else{
if(total_value > 0) r.price.value = commaSplit(total_value);
}
}
function commaSplit(srcNumber) {
var txtNumber = \'\' + srcNumber;
var rxSplit = new RegExp(\'([0-9])([0-9][0-9][0-9][,.])\');
var arrNumber = txtNumber.split(\'.\');
arrNumber[0] += \'.\';
do {
arrNumber[0] = arrNumber[0].replace(rxSplit, \'$1,$2\');
} while (rxSplit.test(arrNumber[0]));
if (arrNumber.length > 1) {
return arrNumber.join(\'\');
}else{
return arrNumber[0].split(\'.\')[0];
}
}
Posted by 홍반장