复制代码代码如下:
fonction textValidate (type) {
code var;
Caractère var;
var lang = document.getElementByid ('lang'). valeur;
var err_msg = "";
if (lang! = "Eng") {
err_msg = "文件夹名不能包含下列字符之一: / n // /: *? /" <> | &, ";
}
autre {
err_msg = "Un nom de dossier ne peut contenir aucun des caractères suivants: / n // /: *? /" <> | &, ";
}
if (type == "input") {
code = window.event.KeyCode;
}
else if (type == "coller") {
code = window.clipboarddata.getData ('texte');
}
else if (type == "drop") {
code = window.event.datatransfer.getData ('texte');
}
autre {
code = arguments.callee.caller.arguments [0] .Which;
}
Var caractères = string.fromCharcode (code);
var txt = new regexp ("[// *, // &, ////, ///, //?, // |, //:, // <, //>, /"] ") ;
if (type == "input") {
if (txt.test (caractère)) {
alert (err_msg);
if (document.all) {
window.event.returnvalue = false;
}
autre {
arguments.callee.caller.arguments [0] .PreventDefault ();
}
}
}
if (type == "coller" || type == "drop") {
if (txt.test (code)) {
alert (err_msg);
window.event.returnvalue = false;
}
}
}