ecommunities/ecms-number-format
Composer 安装命令:
composer require ecommunities/ecms-number-format
包简介
jQuery plugin for input field number formatting and validation
README 文档
README
#####jQuery Plugin for Input Field Number Formatting MIT license: [http://www.opensource.org/licenses/mit-license.php]
Author: Kevin Farley / eCommunities / [http://ecms.io]
GitHub: [http://github.com/ecommunities/ecmsNumberFormat]
This plugin allows you to provide visual validation of a numeric input field (input, number) via addition/removal of classes both during editing, and after leaving the field. In the standard declaration below, we demonstrate how you can validate against a variety of criteria without impeding a users ability to enter data in their own way, and then force the field to update to the closest valid value upon losing focus. Criteria currently include: **min**imum value, **max**imum value, **dec**imal precision, and **inc**rement, but the to-do's include the ability to add additional filters via Regex strings, feel free to fork and PR to lend a hand!
Configuration Parameters
- @param float|null min The minimum value to allow
- @param float|null max The maximum value to allow
- @param int dec The number of decimal places to fix the value to
- @param float inc The increment value to match to
- @param string valid Class name to be added when value is valid (only while field has focus)
- @param string invalid Class name to be added when value is invalid (only while field has focus)
Alternate Field Attribute Parameters
Overrides call time parameters
- min (text|number)
- max (text|number)
- step (number)
Alternate Field Data-Attribute Parameters
Overrides attribute parameters
- data-min
- data-max
- data-dec
- data-inc
- data-valid
- data-invalid
Configuration Examples:
// Defaualt formatting, no decimals, increment by one, no min or max. var numOpts = {} // No min or max, fix to two decimals and round to multiples of 0.25. var numOpts = { dec:2, inc:0.25 }; // Enforce a minimum of 1000 and a maximum of 2000, with no decimals, and increment by one. var numOpts = { min:1000, max:2000 }; // The kitchen sink. var numOpts = { min:1000, max:2000, dec:4, inc:0.0025, valid:'valid-class', invalid:'invalid-class' };
Standard Declaration:
$('#foo').on('keyup paste change', function() { $(this).ecmsNumberValidate(numOpts); }); $('#foo').on('blur', function() { $(this).ecmsNumberFormat(numOpts); }).blur();
TO-DO's
- allow precision to be forced in output (i.e. trailing zeros in html5 number field)
- add support for more numerical types (i.e. scientific notation)
- add support for custom match regex queries in addition to standard options
- add support for helpful error messages
- add example html file + test files / cases
ecommunities/ecms-number-format 适用场景与选型建议
ecommunities/ecms-number-format 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ecommunities/ecms-number-format 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ecommunities/ecms-number-format 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-18