Docly Developers
Function Updated 17 Oct 2026

validateFilename(filename)

Validates that a filename contains only allowed characters.

Parameters

filenamestringrequired

The filename to check. The function returns false if the name is empty, is "." or "..", or contains characters that are not allowed in file names (such as \ / : * ? " < > | and control characters like tab). Leading and trailing spaces are allowed.

Returns

True if valid, false if invalid filename.

Example

Normal JavaScript, running in the browser or on the Docly™ server.
let x = "validfile.txt";
let result = docly.validateFilename(x); // true

let invalid = "not	valid";
result = docly.validateFilename(invalid); // false — contains a tab

result = docly.validateFilename(".."); // false