0

I think this could be put at Web Design part, but maybe the JavaScript is more important
I am reposting this at Web Design
I posted it at JavaScript Forum, that was a mistake

Code:

<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>

<!--
  Simple Login Form
  ** Used with jQuery
-->

<form id='login'>
  <input type='text'     placeholder='username' id='login_name' />
  <input type='password' placeholder='password' id='login_pwd' />
  <input type='submit'   value='Login' />
</form>

<script>
  var logins = [
    ['login', 'pwd']
  ];

  $('#login').submit(function(e) {
    e.preventDefault();

    for(login in logins) {
      if($('#login_name').val() == login[0] && $('#login_pwd').val() == login[1]) {
        loginSuccess();
      }
    }
  });

  function loginSuccess() {
    // If successfully logged in this function will be called

    // Run some function here
  }
</script>

Demo: JSBIN

3
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by toxicandy
0

Your username/password would be visible in the source of the page though would they not? This would be a big security concern. :-)

0

Is this just for testing or learning about JS? Login pages should not be done in JS, it's all client side, how are you storing values to retrive login information of past users. What's the whole purpose of this site?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.