I like krmko's solution, it should be a very robust method.
If it doesn't work out though you can also set a max distance for a raycast and trigger a miss event when it doesn't hit an object.
Layers will come in handy too if you need to enable/disable the jump occurring in certain circumstances. You might consider including a state or two to setup the regrounding process that will prevent your character from endlessly jumping into the air after the initial jump. That will obviously depend on the context of your character controller though.