Abstract X-ray observations provide important and valuable insights into the acceleration and propagation of nonthermal electrons during solar flares. Improved X-ray spectral analysis requires a deeper understanding of the dynamics of energetic electrons. Previous studies have demonstrated that the dynamics of accelerated electrons with a few thermal speeds are more complex than those with significantly higher speeds. To better describe the energetic electrons after injection, a model considering energy diffusion and thermalization effects in flare conditions (the warm-target model) has recently been developed for spectral analysis of hard X-rays. This model has demonstrated how the low-energy cutoff, which can hardly be constrained in cold-target modeling, can be determined. However, the power-law form may not be the most suitable representation of injected electrons. The kappa distribution, which is proposed as a physical consequence of electron acceleration, has been applied successfully in RHESSI spectral analysis. In this study, we employ the kappa-form injected electrons in the warm-target model to analyze two M-class flares, observed by RHESSI and the Spectrometer/Telescope for Imaging X-rays, respectively. The best-fit results show that the kappa-form energetic electron spectrum generates lower nonthermal energy than the power-law form when producing a similar photon spectrum in the fit range. We also demonstrated that the fit parameters associated with the kappa-form electron spectrum can be well determined with small uncertainty. Further, the kappa distribution, which covers the entire electron energy range, enables the determination of key electron properties such as total electron number density and average energy at the flare site, providing valuable information on electron acceleration processes.