سؤال

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: " " };
});
هل كانت مفيدة؟

المحلول

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: " " };
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top