The NinjaMask plugin adds a mask component into a input text element.
NinjaMask
References
Add those references into your website:
And the plugin files:
Call ninjaMask method to initialize the plugin:
$(document).ready(function(){ $("#myMask").ninjaMask('99.999-999'); });
Options
.ninjaMask({ placeholder: null, //-- set a placeholder text charMask: '_', //-- set a char to be used as input mask clear: true, //-- set if the mask will be cleared if it's not valid patterns: { //-- set the char key and regex pattern used as mask validation '9': '[0-9]', //-- only digits 'a': '[A-Za-z]', //-- only chars '*': '[A-Za-z0-9]' //-- digits and chars }, onBlur: null //-- set a function to be fired when the focus leave the input );
Methods
Name |
Description |
Sample |
---|---|---|
ninjaMask(mask, {options}) |
Initialize the plugin to the specified selector. |
$("#myMask").ninjaMask('99.999-999'); |