validateFilename(filename) Last updated: 13. May 2026

Validates that a filename contains only allowed characters.

Parameters

Name Type Description
filename string

The filename to check. The function returns true if the filename is valid, or false if it contains illegal characters such as tabs, leading/trailing spaces, or other disallowed characters.

Returns

True if valid, false if invalid filename.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
let x = "validfile.txt";
let result = docly.validateFilename(x); // will be true

let invalid = " not\t valid";
result = docly.validateFilename(invalid); // will be false