设置EditText只能输入小数点后两位,在价格等有限制的输入时特别有效 TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.toString().contains(".")) { if (s.length() - 1 - s.toString().indexO…
input内强制保留小数点后两位 位数不足时自动补0 小数点后位数超出2位时进行四舍五入 需引入jquery包 1.11.2版本 1 function xiaoshu(x) 2 { 3 var f = parseFloat(x); 4 var f = Math.round(x*100)/100; 5 var s = f.toString(); 6 var rs = s.indexOf('.'); 7 if (rs < 0) { 8 rs = s.length; 9 s += '.'; 10 }…
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>floatDecimal.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta htt…