Though we cannot directly observe free quarks, there are two main types of experiments from which we have been able to probe the properties of individual quarks.
1. Deep Inelastic Scattering experiments. These involve colliding high-energy electrons with nucleons and measuring the scattering angles and outgoing energies of the scattered electrons. At high enough energies, the dominant electromagnetic process in the scattering is the exchange of a single virtual photon between the electron and an individual quark within the nucleon. (Weak interaction processes can also occur, eg through the exchange of a virtual Z0, but I am disregarding these for the purposes of this post.)
2. Electron-Positron collisions. In these the two incoming particles can collide into a state of pure energy such as a single virtual photon. The latter then promotes another particle/antiparticle pair from the vacuum. Subject to the available collision energy, the new particle could be another electron, a muon or tau, or a quark of whatever flavour. In these experiments, the resulting particle types and their energies/momenta can be measured by the detectors. By repeating the experiment a number of times we can also measure the frequency with which each different type of particle is being produced (at each given energy level of the incoming e-e+). In the case of quarks, of course, these either hadronise or decay, so the resulting detectable particles are generally mesons of some or other variety.
It turns out that various measurements obtainable from these experiments depend on the values of the electric charges of the outgoing particles. As well as being proportional to the force experienced by the particle in a given strength of electric fields, the particle's charge also proportional to the probability of it absorbing or emitting a photon. Comapring the actual results with the theoretical expectations confirms the quarks' fractional charge assignments.