A Pen by Save Pongsiri on CodePen.
Created
November 12, 2018 15:35
-
-
Save savepong/e37f257eedcb5b5cae567d63f88eed53 to your computer and use it in GitHub Desktop.
jQuery Input Masks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action=""> | |
<div> | |
<label for="cc">Credit Card</label> | |
<!-- Set via HTML --> | |
<input id="cc" type="text" data-inputmask="'mask': '9999 9999 9999 9999'" /> | |
</div> | |
<div> | |
<label for="date">Date</label> | |
<input id="date" data-inputmask="'alias': 'date'" /> | |
</div> | |
<div> | |
<label for="phone">Phone</label> | |
<!-- or set via JS --> | |
<input id="phone" type="text" /> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(":input").inputmask(); | |
$("#phone").inputmask({"mask": "(999) 999-9999"}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/jquery.inputmask.bundle.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
font-family: monospace; | |
} | |
label { | |
display: block; | |
} | |
div { | |
margin: 0 0 1rem 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment