The present invention relates to a topical film-forming composition including, in a pharmaceutically acceptable medium, at least denatonium benzoate and a chitosan, a chitosan derivative, or a pharmaceutically acceptable salt thereof, as well as to the non-therapeutic use of said composition to treat or prevent onychophagia.