Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

formatjs/input-data-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

input-data-formatter

Format as you type.

  • phone number (XXX) XXX-XXXX, XXXXX-XXXXX
  • credit card number XXXX XXXX XXXX XXXX, XXXX XXXXXX XXXXX
  • date DD/MM/YYYY, MM/DD/YYYY, YYYY/MM/DD

Usage:

<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>

Compatible browsers:

  • Chrome latest (desktop, iOS and Android)
  • Safari latest (desktop and iOS)
  • FireFox (desktop)
  • IE 9+ (desktop)
  • Opera (desktop)

API:

  • enableFormatting
// target = document.getElementById('mobile-number');
window.inputFormatter.enableFormatting (target);
  • getFormattedValue
// value = '1234567890';
// format = '(XXX) XXX-XXXX';
window.inputFormatter.getFormattedValue (value, format)

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published