https://github.com/ntsd/mirrorinput
A library to copy an input element and allow you to custom string to show
https://github.com/ntsd/mirrorinput
Last synced: over 1 year ago
JSON representation
A library to copy an input element and allow you to custom string to show
- Host: GitHub
- URL: https://github.com/ntsd/mirrorinput
- Owner: ntsd
- Created: 2019-01-20T16:45:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T01:57:27.000Z (over 3 years ago)
- Last Synced: 2025-01-23T19:47:10.622Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.4 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Mirrorinput.js
A library to copy an input element and allow you to custom string to show.
#### Features
- Edit value to show as you want without effect primary value
- Number pads for mobile when you need to add text on input field
- Caret selection position when value size is change
- No jQuery need
#### Example
```
function onCreditCardShow(text) {
let newText = "";
let spaces = "";
for (let i in text.split("")) {
if (i%4 == 0) {
newText += " ";
spaces += "0";
}
if (i > 2 && i < 12) {
newText += "*";
} else {
newText += text[i];
}
spaces += "1";
}
return { text: newText, spaces: spaces };
}
var cardMirrorInput = new MirrorInput(document.getElementById("exampleInputCard"), onCreditCardShow);
```
**Warning caret position do not support in type number, email, date**
You can use type text and tel instead