<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function str_split(src_val) {
var txt_num = '' + src_val;
if (isNaN(txt_num) || txt_num == "") {
alert("数字を入力して下さい。");
}
else {
var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
var curr_val = txt_num.split('.');
curr_val[0] += '.';
do {
curr_val[0] = curr_val[0].replace(rxSplit, '$1,$2');
} while (rxSplit.test(curr_val[0]));
if (curr_val.length > 1) {
return curr_val.join('');
}
else {
return curr_val[0].split('.')[0];
}
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<form name="myfrm">
<b>数字を入力 -> </b>
<input type=text name="input_number" size=26 value="">
<input type=button value="カンマを付ける"
onClick="document.myfrm.input_number.value=str_split(document.myfrm.input_number.value);">
</form>
</BODY>
</HTML>
|