Input-data-formatter输入输出格式
Input-data-formatter 能够输入输出你想要的格式
电话号:
(XXX) XXX-XXXX, XXXXX-XXXXX
信用卡号:
XXXX XXXX XXXX XXXX, XXXX XXXXXX XXXXX
日期:
DD/MM/YYYY, MM/DD/YYYY, YYYY/MM/DD
它能够兼容以下浏览器:
Chrome latest (desktop, iOS and Android)
Safari latest (desktop and iOS)
FireFox (desktop)
IE 9+ (desktop)
Opera (desktop)
代码示例:
<input type="tel" id="mobile-number" value="1234567890" data-format="(XXX) XXX-XXXX"> <script src="path/to/input-data-formatter.js"></script> <script> var mobileNumber = document.getElementById('mobile-number'); inputFormatter.enableFormatting(mobileNumber); </script>
API:
enableFormatting
// target = document.getElementById('mobile-number'); window.inputFormatter.enableFormatting (target);
评论