Modal page and button click

I have a modal page with login button. Clicking on the button verifies the username or password. And if incorrect, error messages will be shown while still being inside the modal. But I can not find a way to do this. Please help me.