Modal page and button click

I have a modal page with login button and when I want to click this button and the username or password is incorrect, should be shown error messages and keep the modal. But I can not how to do this. Please help me.