|
|
|
javascript จัด format number ให้อยู่ในรูปแบบ ### ### #### |
|
|
|
|
|
|
|
Code (JavaScript)
<html>
<body>
<form name="frmMain" action="" method="post">
<script language="JavaScript">
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function chkNum(ele)
{
var num = parseFloat(ele.value);
ele.value = addCommas(num.toFixed(2));
}
</script>
<input type="text" name="txtNumber" value="" OnChange="JavaScript:chkNum(this)">
</form>
</body>
</html>
Apply จากตัวนี้ครับ
|
|
|
|
|
Date :
2014-06-10 17:40:54 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|