Question

I'm trying to use the masked input JQuery plugin so that my textbox will not accept any special characters which will not be allowed in a Windows Filename system. I'm searching for the .mask parameter to do this but haven't had any luck yet. This code will not allow special characters but it only allows the user to enter in two characters. The minimium length of my textbox is 15

jQuery(function ($) {
    $('#KnowledgebaseTitle').mask("a*"), { placeholder: " " };
});
Était-ce utile?

La solution

If you need 15 character length no special chars then:

jQuery(function ($) {
    $('#KnowledgebaseTitle').mask("***************"), { placeholder: " " };
});

'a' is for aphla chars.

If you need to make a custom mask filter then use:

$.mask.definitions['h'] = "[A-Fa-f0-9]"; // your regex filter etc...

I think this regex expression will work for windows special chars:

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

jQuery(function ($) {
    $('#KnowledgebaseTitle').mask("hhhhhhhhhhhhhhh"), { placeholder: " " };
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top