复制代码 代码如下:
function TextValidate(type) {
var code;
var character;
var Lang = document.getElementById('Lang').value;
var err_msg = "";
if (Lang != "Eng") {
err_msg = "文件夹名稱不能包含下列字符之一:\n \\ / : * ? \" < > | & , ";
}
else {
err_msg = "A Folder Name cannot contain any of the following characters:\n \\ / : * ? \" < > | & ,";
}

if (type == "input") {
code = window.event.keyCode;
}
else if (type == "paste") {
code = window.clipboardData.getData('Text');

}
else if (type == "Drop") {
code = window.event.dataTransfer.getData('Text');

}
else {
code = arguments.callee.caller.arguments[0].which;
}
var character = String.fromCharCode(code);
var txt = new RegExp("[\\*,\\&,\\\\,\\/,\\?,\\|,\\:,\\<,\\>,\"]");
if (type == "input") {
if (txt.test(character)) {
alert(err_msg);
if (document.all) {
window.event.returnValue = false;
}
else {
arguments.callee.caller.arguments[0].preventDefault();
}
}
}
if (type == "paste" || type == "Drop") {
if (txt.test(code)) {
alert(err_msg);
window.event.returnValue = false;
}
}
}
标签:
过滤字符

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com