JS显示问题 急!!! 要实现这样是个财务数的展示问题例如输入框中有33333,显示为33,333当输入金额的时候,也自动每三个进行分割,还有就是如果直接赋值 例如从数据库查出个数,显示为每三个用,分割 怎么分割 谢谢啦 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>aaa</title></head><body><input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='1223123123'><script type="text/javascript">window.onload = function(){ var ss =document.getElementById('ss'); formatnum.call(ss,ss,ss.value); //直接赋直就调用下}function formatnum(o,s){ o.value = s.replace(/[^\d]+/g,'').replace(reg1,'$1,')}</script></body></html> 上面的正则写掉了 无视吧<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>eee</title></head><body><input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='12123123123'><script type="text/javascript">window.onload = function(){ var ss =document.getElementById('ss'); formatnum.call(ss,ss,ss.value);}function formatnum(o,s){ o.value = s.replace(/[^\d]+/g,'').replace(/(\d{1,3})(?=(\d{3})+$)/g,'$1,')}</script></body></html> var n = 66666.4;alert(n.toLocaleString()); 不好意思 可能之前我说的不够明白,在HTML的文本框内,显示用“ ,”分割的金额,也就是千分位显示(例如29,897.00元),当点击文本框,每输入一个数字,就自动按照千分位排列, 特殊的情况是当这个数不是整数,有小数位的时候,这个小数点后面的是不需要千分位显示,有几位小数就几位小数,麻烦哪位大侠给做个例子啊 用ASP.net 前台用一个JS方法,后台在做一个,因为有时候这个数我需要从数据库查出来赋值 急急急!!!!!!! var n = 66666.4;alert(n.toLocaleString()); toLocaleString : StringReturns a string representing the number that follows local formatting conventions.Supported: IE 5.5+, Mozilla 1.0+, Netscape 6.0+, Opera 7.0+, Safari 1.0+ js或jquery 即时加减吗? svg 鼠标坐标 点击onclick事件触发调用其他JS文件 html 标签select中的option 自定义属性 如何实现 ASP 调用横向排列后可以自动换行? 文本框太短,显示不完整,如何获得焦点时,提示??? 画一个边框为红色的,透明的矩形框,急用 请问在RDS对象中怎么写出oracle的连接字符串connect与server属性 在css中想使用绝对路径来定位图片.但又不能确定web服务器名,要怎样才能在css中得到web服务器名呢? 同名的复选框的判断,该怎么做呢? 散分 js里判断出来之后能执行alert却不执行别的,大家来帮帮忙
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>aaa</title></head>
<body>
<input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='1223123123'>
<script type="text/javascript">
window.onload = function(){
var ss =document.getElementById('ss');
formatnum.call(ss,ss,ss.value); //直接赋直就调用下
}
function formatnum(o,s){
o.value = s.replace(/[^\d]+/g,'').replace(reg1,'$1,')
}
</script></body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>eee</title></head>
<body>
<input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='12123123123'>
<script type="text/javascript">
window.onload = function(){
var ss =document.getElementById('ss');
formatnum.call(ss,ss,ss.value);
}
function formatnum(o,s){
o.value = s.replace(/[^\d]+/g,'').replace(/(\d{1,3})(?=(\d{3})+$)/g,'$1,')
}</script></body>
</html>
var n = 66666.4;
alert(n.toLocaleString());
alert(n.toLocaleString());
Returns a string representing the number that follows local formatting conventions.
Supported: IE 5.5+, Mozilla 1.0+, Netscape 6.0+, Opera 7.0+, Safari 1.0+