$\vec{F}=q\vec{v}\times\vec{B}$.
The following show a charged particle trapped bwtween two uniform field.
You can use sliders to change the width and the separation between two sets of magnet.
The magnetic field is assumed to be uniform $Bz\hat{z}$ inside the magnet region. and the field is zero when outside the boundary.

You can change the location and velocity of the charged particle with mouse drag and drop or with sliders.