In simplest terms, valency is a measure of number of electrons that can be used by an element in the bond formation. The bonds between two elements can be formed by either electron donation/accepting (i.e. ionic bonds) or by electron sharing (covalent bonds). The easiest way to determine the valency of an element is to write its electron configuration and determine how many more electrons are needed to achieve a fully filled configuration or how many electrons will have to be lost to gain the fully filled (or noble gas) configuration. This information coupled with whether an element would be a likely donor (e.g., metals) or acceptor (e.g., non-metals) of electrons, can give a good idea about its valency. For example, sodium has an atomic number of 11 and its electronic configuration is 1s2, 2s2, 2p6, 3s1. That is, it has only one valence electron and, being a metal, is likely to be a donor, so its valency is 1. In comparison, the atomic number of chlorine is 17 and its configuration would be 1s2, 2s2, 2p6, 3s2, 3p5. It lacks 1 electron to a fully filled orbital, and being a non-metal will likely accept it from a metal, and hence also has a valency of 1.
Kindly note that, depending on its chemistry, an element may have more than one valency.
Hope this helps.