JQuery Masked Input - No Illegal Filename Characters

谁说胖子不能爱 提交于 2020-01-06 19:39:54

问题


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: " " };
});

回答1:


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: " " };
});


来源:https://stackoverflow.com/questions/22731654/jquery-masked-input-no-illegal-filename-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!