[javascript] 자바스크립트 number_format
로빈아빠
본문
<scRIPT LANGUAGE="Javascript">
<!--
function Number_Format(fn){
var str = fn.value;
var Re = /[^0-9]/g;
var ReN = /(-?[0-9]+)([0-9]{3})/;
str = str.replace(Re,'');
while (ReN.test(str)) {
str = str.replace(ReN, "$1,$2");
}
fn.value = str;
}
//-->
</scRIPT>
<FORM name=fm METHOD=POST ACTION="">
<INPUT TYPE="text" NAME="money" onkeyup="Number_Format(this)";>
</FORM>
<!--
function Number_Format(fn){
var str = fn.value;
var Re = /[^0-9]/g;
var ReN = /(-?[0-9]+)([0-9]{3})/;
str = str.replace(Re,'');
while (ReN.test(str)) {
str = str.replace(ReN, "$1,$2");
}
fn.value = str;
}
//-->
</scRIPT>
<FORM name=fm METHOD=POST ACTION="">
<INPUT TYPE="text" NAME="money" onkeyup="Number_Format(this)";>
</FORM>
관련링크
댓글목록
등록된 댓글이 없습니다.