JSFiddle - React, Tailwind, and code Playground
by neoswf
HTML
<script src="https://nosir.github.io/cleave.js/dist/cleave.min.js"></script>
<script src="https://nosir.github.io/cleave.js/dist/cleave-phone.au-cn.js"></script>
<div class="container">
<input class="input-phone" type="text" placeholder="my test" />
<input class="input-phone-au" placeholder="Australia phone number: eg. 0412000111" />
<input class="input-phone-cn" placeholder="China phone number: eg. 13900001111" />
</div>
CSS
* {
box-sizing: border-box;
}
.container {
width: 300px;
}
button {
margin-bottom: 15px;
width: 100%;
height: 24px;
outline: none;
-webkit-appearance: none;
border: 1px solid #e6e6e6;
border-radius: 5px;
background-color: #fff;
font-size: 13px;
}
.input-credit-card {
margin-bottom: 5px;
}
input {
display: block;
outline: none;
-webkit-appearance: none;
border: 1px solid #e6e6e6;
border-radius: 5px;
background-color: #fff;
line-height: 30px;
vertical-align: middle;
height: 33px;
width: 100%;
font-size: 14px;
padding: 0 8px;
margin-bottom: 15px;
}
.input-numeral {
text-align: right;
}
body {
font-family: sans-serif;
}
a,
a:hover {
color: #999;
}
a {
font-size: 14px;
margin-top: 20px;
}
JavaScript
var cleave = new Cleave('.input-phone', {
phone: true,
phoneRegionCode: 'BR'
});
var cleavePhone1 = new Cleave('.input-phone-au', {
phone: true,
phoneRegionCode: 'AU'
});
var cleavePhone2 = new Cleave('.input-phone-cn', {
phone: true,
phoneRegionCode: 'CN'
});