Yes, it's fine. You can also say "at the beach", but it has a subtle difference.
On the beach means that you are physically standing on the sand along the ocean. It is more precise.
We took a walk on the beach. (not
at)
At the beach simply means that you were there, maybe in the vicinity.
We were at the beach all day (maybe you visited a few shops or restaurants nearby). If you were to say that you were
on the beach all day, then it would emphasize that you never left the actual beach.
I hope that has helped.