Flash local authentication backend poll project

I have the session and authentication working on my poll project. I have drop down forms from a nav-bar for the log-in and sign-up. The local authentication works and sends back a flash message if the username is not unique and will display it on my jade page. I want to put the flash message on the drop down menu and then close the menu if there isn’t any flash message, so it doesn’t close when you hit the submit button. How can I do this or can you point to something to read?