Client side validation/error handling

It's not complete, but it should be enough for now.