Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active January 17, 2016 01:16
Show Gist options
  • Select an option

  • Save jendiamond/261299f078a149122f73 to your computer and use it in GitHub Desktop.

Select an option

Save jendiamond/261299f078a149122f73 to your computer and use it in GitHub Desktop.

JavaScript Workshop Week 2

Primitives datatypes

-string -int -float -objects -undefined

===

sort comes from the arrary's protype - ability to add funtionality to an object that already exists in javascript

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <form id="myForm" onsubmit= "return grabForm();" method="POST">
  <h1>Login</h1>
    <input id="name" type="text" name="username" value="" placeholder="Enter your name"><br/>
    <input id="password" type="password" name="password" value="" placeholder="Enter your Password"><br/>
    <button>SUBMIT</button>
  </form>
  
  <script>
    function grabForm() {
      var name = document.getElementById('name').value;
      var password = document.getElementById('password').value;
      if(name == null || name == ""){
      alert('Please enter a name);
      return false;
      }
      alert(name + " " + password);
    }
  </script>
</body>
</html>

http://www.w3schools.com/js/js_validation.asp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment