9/4/2017 - 5:22 PM

Sign In / Sign Up example

Sign In / Sign Up example

<!DOCTYPE html>
<html lang="en-us">


  <meta charset="UTF-8">
  <title>Sign-Up Today!</title>

  <!-- Bootstrap -->
  <link rel="stylesheet" href="" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">



  <div class="container">


    <!-- Jumbotron -->
    <div class="jumbotron">
      <h1 class="text-center">Sign-Up Today!</h1>

    <div class="row">

      <!-- Sign-Up Panel-->
      <div class="col-lg-6">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">New Member Sign-Up</h3>
          <div class="panel-body">

            <!-- Sign-up Form (note the various input "types")-->
            <form role="form">
              <div class="form-group">
                <label for="name-input">Name:</label>
                <input class="form-control" id="name-input" type="text">
              <div class="form-group">
                <label for="email-input">Email:</label>
                <input class="form-control" id="email-input" type="email">
              <div class="form-group">
                <label for="age-input">Age:</label>
                <input class="form-control" id="age-input" type="number">
              <div class="form-group">
                <label for="comment-input">How did you hear about us?</label>
                <textarea class="form-control" id="comment-input" rows="5"></textarea>
              <button class="btn btn-default" id="add-user" type="submit">Submit</button>

      <!-- Most Recent Member Panel -->
      <div class="col-lg-6">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">Most Recent Member</h3>
          <div class="panel-body" id="recent-member">
            <h2 id="name-display">Jimmy John</h2>
            <h4 id="email-display">Email:</h4>
            <h4 id="age-display">Age: 27</h4>
            <p id="comment-display">I'm signing up, because I want to spread sandwiches to the world.</p>



  <!-- jQuery -->
  <script src=""></script>

  <!-- JavaScript -->
    // Capture Button Click
    $("#add-user").on("click", function(event) {
      // prevent page from refreshing when form tries to submit itself

      // Capture user inputs and store them into variables
      var name = $("#name-input").val().trim();
      var email = $("#email-input").val().trim();
      var age = $("#age-input").val().trim();
      var comment = $("#comment-input").val().trim();

      // Console log each of the user inputs to confirm we are receiving them

      // Replaces the content in the "recent-member" div with the new info

      // Clear localStorage

      // Store all content into localStorage
      localStorage.setItem("name", name);
      localStorage.setItem("email", email);
      localStorage.setItem("age", age);
      localStorage.setItem("comment", comment);

    // By default display the content from localStorage