复制代码代码如下:
função textValidate (tipo) {
Código var;
personagem var;
var lang = document.getElementById ('Lang').
var err_msg = "";
if (lang! = "Eng") {
err_msg = "文件夹名不能包含下列字符之一: /n // /: *? /" <> | &, ";
}
outro {
err_msg = "Um nome de pasta não pode conter nenhum dos seguintes caracteres: /n // /: *? /" <> | &, ";
}
if (type == "input") {
código = window.event.keycode;
}
caso contrário, se (tipo == "pasta") {
code = window.clipboarddata.getData ('text');
}
caso contrário, if (type == "gota") {
code = window.event.datatransfer.getData ('text');
}
outro {
code = argumentos.callee.caller.argudents [0] .Which;
}
var caractere = string.fromCharCode (código);
var txt = new regexp ("[//*, // &, ////, ///, //?, // |, // :, // <, //>,/"] ") ;
if (type == "input") {
if (txt.test (caractere)) {
alert (err_msg);
if (document.all) {
window.Event.ReturnValue = false;
}
outro {
argumentos.callee.caller.argudents [0] .PreventDefault ();
}
}
}
if (type == "paste" || tipo == "gota") {
if (txt.test (code)) {
alert (err_msg);
window.Event.ReturnValue = false;
}
}
}