A simple masking library for javascript input
CDN
<script src="https://fieldmask.github.io/cdnjs/0.1.0/fieldmask.js"></script>
<input type="text" fieldmask="maskname"> <!-- 'maskname' -->
<!-- cdn -->
<script src="https://fieldmask.github.io/cdnjs/0.1.0/fieldmask.js"></script>
<script>
fieldmask()
</script>
Mask Name | Mask Format |
---|---|
cpf | 000.000.000-00 |
cnpj | 00.000.000/0000-00 |
tel | 0000-0000 |
ddd+tel | (00) 0000-0000 |
cel | 00000-0000 |
ddd+cel | (00) 00000-0000 |
cep | 00000-000 |
date | 00/00/0000 |
time | 00:00:00 |
dateTime | 00/00/0000 00:00:00 |
currency | ["000.000.000,00", { reverse: true}] |
centimeter | ["000", { reverse: true, suffix: "cm" }] |
meter | ["0000", { reverse: true, suffix: "m" }] |
ip | 000.000.000.000 |
letter | [a-z] [A-Z] |
number | [0-9] |
Indicator for define mask: 0
<input type="text" fieldmask="date">
fieldmask({
'date': '00-00-0000'
})
fieldmask({
'customMaskName': string | [maskFormat, options?: {
reverse: boolean, // Reverse the typing start side
prefix: string, // prefix+mask
suffix: string, // mask+suffix
}]
})
<input type="text" fieldmask="real">
fieldmask({
'real': ['00,00', {prefix: 'R$', reverse: true}]
})
©fieldmask | License MIT