One way this is usually done is by detecting whether the character is on the ground or not
So if you have "continuous" bottom collision, you allow for full left/right movement.
If the player is in the air, you restrict the left/right movement but make sure to apply gravity.
Here is a very imperfect example I wrote a long time ago. It's very simplified and lots of potential to change, but maybe it can give you an idea.