Ultracool dwarfs encompass a wide variety of compact stellar-like objects with spectra classified as late-M, L, T and Y. Most of them have been discovered using wide-field imaging surveys. The Virtual Observatory has proven to be of great utility to efficiently exploit these astronomical resources. We aim to validate a Virtual Observatory methodology designed to discover and characterize ultracool dwarfs in deep extragalactic surveys like ALHAMBRA and COSMOS. Three complementary searches based on parallaxes, proper motions and colours, respectively were carried out. A total of 897 candidate ultracool dwarfs were found, with only 16 previously reported in SIMBAD. Most of the new UCDs reported here are likely late-M and L dwarfs because of the limitations imposed by the utilization of optical ($Gaia$ DR2 and r-band) data. We complement ALHAMBRA and COSMOS photometry with other catalogues in the optical and infrared using VOSA, a Virtual Observatory tool that estimates effective temperatures from the spectral energy distribution fitting to collections of theoretical models. The agreement between the number of UCDs found in the COSMOS field and theoretical estimations together with the low false negative rate (known UCDs not discovered in our search) validates the methodology proposed in this work, which will be used in the forthcoming wide and deep surveys provided by the Euclid space mission. Simulations of Euclid number counts for UCDs detectable in different photometric passbands are presented for a wide survey area of 15,000 square degrees, and the limitations of applicability of Euclid data to detect UCDs using the methods employed in this paper are discussed.