Skip to content

Instantly share code, notes, and snippets.

@dogrocker
Last active September 12, 2015 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogrocker/e82582c37df73c440355 to your computer and use it in GitHub Desktop.
Save dogrocker/e82582c37df73c440355 to your computer and use it in GitHub Desktop.
jQuery & Inputmask with validator and convert text to uppercase.

Example of jQuery inputmask.

  • html form
<input id="test" type="text"></input>
<button id="btn">click</button>
  • css
#test {
    text-transform:uppercase;
}
  • js
$('#test').inputmask({
    mask: "99-99-99",
    definitions: {'9': {validator: "[a-zA-Z0-9]"}}
});
$('#test').focus();
$('#btn').click(function(){
    $('#test').prop('value', $('#test').val().toUpperCase());
    console.log($('#test').val());
    console.log($('#test').prop('value'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment