A Pen by Chris Coyier on CodePen.
Created
June 14, 2019 20:34
-
-
Save ldavidsp/5de352cbd990c40c5827628c691df9a3 to your computer and use it in GitHub Desktop.
jQuery Input Masks
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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