jQuery EasyUI/TopJUI基本的数字输入框(保留两位小数,带前缀后缀...)

numberbox(数值输入框)

HTML

required:必填字段,默认为false;prompt:显示在输入框的提示性文字;min/miax:最小/最大值;
precision:保留的小数位数;prefix:'¥':带前缀;suffix:'$':带后缀;groupSeparator:','字符分割整数组

  

    <fieldset>
<legend>基本数字输入框</legend>
</fieldset> <div class="topjui-row">
<div class="topjui-col-sm6">
<label class="topjui-form-label">年龄</label>
<div class="topjui-input-block">
<input type="text" name="age" data-toggle="topjui-numberbox"> //自然数
</div>
</div>
<div class="topjui-col-sm6">
<label class="topjui-form-label">工龄</label>
<div class="topjui-input-block">
<input type="text" name="gonglin" data-toggle="topjui-numberbox"
data-options="required:true,prompt:'工龄是必填字段'">
</td>
</div>
</div>
</div> <fieldset>
<legend>最大最小值限制</legend>
</fieldset> <div class="topjui-row">
<div class="topjui-col-sm6">
<label class="topjui-form-label">年龄</label>
<div class="topjui-input-block">
<input type="text" name="age" data-toggle="topjui-numberbox"
data-options="min:18,max:120,prompt:'输入范围18至120之间'">
</div>
</div>
<div class="topjui-col-sm6">
<label class="topjui-form-label">工龄</label>
<div class="topjui-input-block">
<input type="text" name="gonglin" data-toggle="topjui-numberbox"
data-options="required:true,min:1,max:60,prompt:'输入范围1到60之间'">
</td>
</div>
</div>
</div> <fieldset>
<legend>带精度的数值输入框</legend>
</fieldset> <div class="topjui-row">
<div class="topjui-col-sm6">
<label class="topjui-form-label">年龄</label>
<div class="topjui-input-block">
<input type="text" name="age" data-toggle="topjui-numberbox"
data-options="precision:2,prompt:'保留2位小数'">
</div>
</div>
<div class="topjui-col-sm6">
<label class="topjui-form-label">工龄</label>
<div class="topjui-input-block">
<input type="text" name="gonglin" data-toggle="topjui-numberbox"
data-options="precision:1,prompt:'保留1位小数'">
</td>
</div>
</div>
</div> <fieldset>
<legend>带标识的数值输入框</legend>
</fieldset> <div class="topjui-row">
<div class="topjui-col-sm6">
<label class="topjui-form-label">工资</label>
<div class="topjui-input-block">
<input type="text" name="age" data-toggle="topjui-numberbox"
data-options="prefix:'¥',prompt:'带前缀的输入'">
</div>
</div>
<div class="topjui-col-sm6">
<label class="topjui-form-label">奖金</label>
<div class="topjui-input-block">
<input type="text" name="gonglin" data-toggle="topjui-numberbox"
data-options="suffix:'$',prompt:'带后缀的输入'">
</div>
</div>
</div> <fieldset>
<legend>带格式化的数值输入框</legend>
</fieldset> <div class="topjui-row">
<div class="topjui-col-sm6">
<label class="topjui-form-label">工资</label>
<div class="topjui-input-block">
<input type="text" name="age" data-toggle="topjui-numberbox"
data-options="groupSeparator:',',prompt:'输入123456789试试'">
</div>
</div>
<div class="topjui-col-sm6">
<label class="topjui-form-label">奖金</label>
<div class="topjui-input-block">
<input type="text" name="gonglin" data-toggle="topjui-numberbox"
data-options="groupSeparator:',',precision:2,prompt:'输入1234567.89试试'">
</div>
</div>
</div>
</div>

  js

<input type="text" id="nn">

$('#nn').iNumberbox({
min:0,
precision:2
});

  设置输入框的值

$('#nn').iNumberbox('setValue', 206.12);

  获取输入框的值

var v = $('#nn').iNumberbox('getValue');
alert(v);

  

EasyUI中文网:http://www.jeasyui.cn

TopJUI前端框架:http://www.topjui.com

TopJUI交流社区:http://ask.topjui.com

jQuery EasyUI/TopJUI基本的数字输入框(保留两位小数,带前缀后缀...)的更多相关文章

  1. layui table 前台数字格式保留两位小数,不足补0(mysql 数据库)

    layui table 对于后台json数据,有数字的,默认不会原样显示,而是只取数值,即100.00显示为100.如果想原样显示,需转为字符串. 项目采用mysql数据库,字段类型为decimal( ...

  2. vue input框数字后保留两位小数正则

    <el-input type="text" v-model.trim="ruleForm2.marketPrice" maxlength="10 ...

  3. js-格式化数字保留两位小数-带千分符

    很多时候发现有时候js会提示自带函数不能使用,所以自己找了很多资料实现了个 html <input type="text" class="input_text in ...

  4. td内的所有数字格式化保留两位小数

    $("td").each(function(i,el){ var td = parseFloat($(el).text()); if(!isNaN(td)){ $(el).text ...

  5. (Math.round(num*100)/100).toFixed(2); 将输入的数字变成保留两位小数

    <input type="number" @input="onInputPrice" @blur="onPrice" data-id= ...

  6. js保留两位小数的数字格式化方法

    // 格式化数字(保留两位小数) numberFormat (num) { let percent = Number(num.toString().match(/^\d+(?:\.\d{0,2})?/ ...

  7. Java保留两位小数的几种做法

    1.  String类型数字始终保留两位小数 , RoundingMode.HALF_UP); return bd.toString(); } /** * 使用DecimalFormat,保留小数点后 ...

  8. Oracle中保留两位小数

    在最近的项目开发中,有个业务需求是界面显示的数字需要保留两位小数,目前我想到的解决方法有两种: (1)在写SQL的时候,直接保留两位小数 (2)在java代码里面将查询出来的数进行格式化处理,保留两位 ...

  9. JS限制input输入的为数字并且有小数的时候最多保留两位小数

    JS限制input用户输入的为数字并且有小数的时候最多保留两位小数,代码如下: html部分: <input type="number" onkeypress="r ...

随机推荐

  1. appium不支持Android7.0系统设备解决办法

    1. 找到appium的安装目录下的adb.js文件. 2. 打开adb.js,手动修改该文件下的内容: Adb.prototype.getPIDsByName=function(name,cb){ ...

  2. jquery 用addClass之后 class有对应的事件,为什么要重新绑定一下事件呢

    假设有元素A,B,C,其中A和B都有class属性cls,如果在页面加载完成时,给具有class属性为cls的元素绑定某一事件,例如click,执行事件时调用alert.也就是说,页面加载完成后A和B ...

  3. sqlite:多线程操作数据库“database is locked”解决方法

    1. 使sqlite支持多线程(不确定是否非加不可,暂且加上,以备后患) 可以在编译时/启动时/运行时选择线程模式,参考:http://www.cnblogs.com/liaj/p/4015219.h ...

  4. unbuntu下安装qq

    由于Wine QQ一直没更新版本导致目前版本报版本过低无法使用,暂时先上UK官网的国际版Wine QQ,虽然功能没那么新,但稳定能用: 下载: 下载地址:http://www.ubuntukylin. ...

  5. ACM学习历程——HDU5017 Ellipsoid(模拟退火)(2014西安网赛K题)

    ---恢复内容开始--- Description Given a 3-dimension ellipsoid(椭球面) your task is to find the minimal distanc ...

  6. AIM Tech Round 4 (Div. 2)

    A题 分析:暴力 #include "iostream" #include "cstdio" #include "cstring" #inc ...

  7. [Codeforces 452E] Three Strings

    [题目链接] https://codeforces.com/contest/452/problem/E [算法] 构建后缀数组 用并查集合并答案即可 时间复杂度 : O(NlogN) [代码] #in ...

  8. 【LeetCode】040. Combination Sum II

    题目: Given a collection of candidate numbers (C) and a target number (T), find all unique combination ...

  9. The Django Book 2.0--中文版

    Table of contents 2.0, English -> Chinese 第一章:介紹Django阅读 01 第二章 入门阅读 02 第三章 视图和URL配置阅读 03 第四章:模版阅 ...

  10. POJ 3258 最小值最大化 二分搜索

    题意:牛要到河对岸,在与河岸垂直的一条线上,河中有N块石头,给定河岸宽度L,以及每一块石头离牛所在河岸的距离, 现在去掉M块石头,要求去掉M块石头后,剩下的石头之间以及石头与河岸的最小距离的最大值. ...