All Projects → tianxiangbing → format-number

tianxiangbing / format-number

Licence: other
文本框数字格式化

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to format-number

React Phone Input 2
📞 Highly customizable phone input component with auto formatting
Stars: ✭ 446 (+2523.53%)
Mutual labels:  format, number
yii2-number
A number format mask control and input for Yii2 Framework
Stars: ✭ 22 (+29.41%)
Mutual labels:  format, number
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (+11.76%)
Mutual labels:  format, number
Translatedjs
Internationalization and localization for JavaScript and Node.js
Stars: ✭ 17 (+0%)
Mutual labels:  format, number
cashaddrjs
CashAddr.js: The new Bitcoin Cash address format for Node.js and web browsers.
Stars: ✭ 36 (+111.76%)
Mutual labels:  format
phonenumber
With a given country and phone number, validate and format the MOBILE phone number to E.164 standard
Stars: ✭ 108 (+535.29%)
Mutual labels:  number
Uncrustify
Code beautifier
Stars: ✭ 2,442 (+14264.71%)
Mutual labels:  format
Activitystreams
Activity Streams 2.0
Stars: ✭ 185 (+988.24%)
Mutual labels:  format
winston-dev-console
Winston@3 console format aimed to improve development UX
Stars: ✭ 88 (+417.65%)
Mutual labels:  format
jQuery.EAN13
A jQuery & plain JavaScript library for generating EAN13-barcodes
Stars: ✭ 45 (+164.71%)
Mutual labels:  number
break infinity.js
A replacement for decimal.js for incremental games who want to deal with very large numbers (bigger in magnitude than 1e308, up to as much as 1e(9e15) ) and want to prioritize speed over accuracy.
Stars: ✭ 145 (+752.94%)
Mutual labels:  number
jodaTime
Format and Parse date and time with joda layout
Stars: ✭ 67 (+294.12%)
Mutual labels:  format
phpF
Format PHP code
Stars: ✭ 34 (+100%)
Mutual labels:  format
max-safe-integer
ES2015 Number.MAX_SAFE_INTEGER ponyfill
Stars: ✭ 15 (-11.76%)
Mutual labels:  number
lrng
Linux Random Number Generator
Stars: ✭ 57 (+235.29%)
Mutual labels:  number
Vuetify Daterange Picker
The missing date range picker for Vuetify JS you have been looking for.
Stars: ✭ 192 (+1029.41%)
Mutual labels:  format
FormatEditText
格式化输入框,可用来格式化数字、金额、号码等; FormatEditText can be used as a formatted text input box
Stars: ✭ 121 (+611.76%)
Mutual labels:  format
from-exponential
Lightweight module to convert number from exponential notation to a human readable string.
Stars: ✭ 27 (+58.82%)
Mutual labels:  number
Truth
A Domain Representation Language
Stars: ✭ 23 (+35.29%)
Mutual labels:  format
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (+94.12%)
Mutual labels:  format

format-number

文本框数字或金额格式化 效果如下图:

数字格式化

Demo请点击数字格式化demo

演示代码

<script src="../src/jquery-1.11.2.js"></script>
<script src="../src/format-number.js"></script>
<div>整数:<input type="text" data-type="int" data-name="int"/></div>
<script>
	var n1 = new FormatNumber();
	n1.init({trigger:$('[data-type="int"]'),decimal:0});
</script>
<div>整数可为负:<input type="text" data-type="int2" data-name="int"/></div>
<script>
	var n2 = new FormatNumber();
	n2.init({trigger:$('[data-type="int2"]'),decimal:0,minus:true});
</script>
<div>两位小数(默认):<input type="text" class="has-minus" value="1112212.221" data-type="number" data-name="as"/></div>
<script>
	var n3 = new FormatNumber();
	n3.init({trigger:$('[data-type="number"]')});
</script>
<div>3位小数并且可为负数:<input type="text" data-name="pc" data-type="pecent"/></div>
<script>
	var n4 = new FormatNumber();
	n4.init({trigger:$('[data-type="pecent"]'),decimal:3,minus:true});
</script>
<div>4位小数并且不可为负数:<input type="text" data-name="pc" data-type="pecent2"/></div>
<script>
	var n5 = new FormatNumber();
	n5.init({trigger:$('[data-type="pecent2"]'),decimal:4});
</script>
<div>标签:123123123.13211=<span id="sp_number">123123123.13211</span></div>
<script>
$('#sp_number').FormatNumber({decimal:4})
</script>

API

属性

trigger:dom|string

触发器元素,可为input或标签元素(span/div)

parent :dom|string

委托对象,由于本插件对事件的绑定都以委托为主,如不传,默认代理到body上

decimal: int

小数位数,默认2位

minus: bool

是否支持负数,默认为false不支持

update:function

动态更新参数
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].