Copy codeThe Code is as follows:
Function TextValidate (type ){
Var code;
Var character;
Var Lang = document. getElementById ('lang '). value;
Var err_msg = "";
If (Lang! = "Eng "){
Err_msg = "the folder name example cannot contain one of the following characters: \ 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;
}
}
}