javascript - jquery click function already clicked/executed on page -


i have following function:

    $(document).ready(function()     {         $('#login-trigger').click(function()         {             $(this).next('#login-content').slidetoggle();             $(this).toggleclass('active');                        if ($(this).hasclass('active')) $(this).find('span')             else $(this).find('span')         })     }); 

when clicks button, login form drops down. however, if type incorrect login information , page reloads error message below form, how can make button has been clicked , form displayed? right now, if type in wrong information, page reloads , not logged in. see error, must click drop down login form see error. confuse people , doesn't make sense.

if understood question:

first of this:

if ($(this).hasclass('active')) $(this).find('span')             else $(this).find('span') 

if has .active class find span, , if didn't find span anyway? , it?

secondly, in stateless mode can't retrieve information of type (like example if user has tried login or not) last session, need either have don in back-end (php, node, etc.) or save data on users browser (cookies, localstorage) in case (authentication) not recommended.

so you're gonna need let server answer login request, according answer, use javascript (or simpler , more preferably css) show visual presentation user, , never try check validation of user login information in front-end.

i hope helps.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -