How to constrain edge slide to axis?
This is due to the extra edge you have on the top surface.

You can enable clamp (hold Alt or press C) after sliding the edge far away from it, but it's not perfect. Removing the edge works best, if you don't need it:





To get an edge where you've indicated, you might find it easier to use the knife tool, at least in this case:


Line up the view with the orientation you want the edge to be in (and ensure you're in orthographic view, numpad 5)
Start the knife tool with K
Click the top vertex, enable angle constrain (C)
Click the bottom edge:




Note that there are many ways you can go about doing this, for example vertex snapping combined with axis constraints can solve this and many similar puzzles:


Set the snapping type to Vertex
Grab (G) the top vertex and hold Ctrl to snap it to other vertices.
Grab the bottom vertex, constrain to the the X Y plane (ShiftZ), and hold Ctrl while hovering over the top vertex.