Search code examples
jquerymaskedinput

jquery masked input definitions


I found this definition as an answer by "popo" to another question:

$.mask.definitions['h'] = "^[\\\\/:*?\"<|]?[\\\\/:*?\"<|]*";
           //period was here ^

but for some reason this allows periods, even though I removed the period from the definition (it was inside the first opening bracket).

I just want a definition that allows the generic alphanumeric, and some special characters like slashes, dashes, and underscores. How can I change the definition above to do that?


Solution

  • If you just need alphanumeric, slash, dash and underscore, then you can use the following:

    $.mask.definitions['h'] = "[A-Za-z0-9\/\-_]";