title: How do I check if input is blank/not blank and do specific thing
body: <p>Okay so I know this is probably a headache for most of you but i'm having trouble figuring this out as javascript is not my strong suit.</p>
  <p>I'm trying to basically get this one page to load if username and password is not blank but if it is blank I want it to alert to me (specifically window.alert()) that I have not inputted username and/or password.
  I cannot seem to figure it out so here it is.</p>
  <pre><code>&lt;button type=&quot;submit&quot; id=&quot;enterButton&quot; onclick=&quot;newPage()&quot;&gt;&lt;strong&gt;Enter&lt;/strong&gt;&lt;/button&gt;
  </code></pre>
  <p>there is my button where I put my function on</p>
  <pre><code>var username = getElementById(&quot;userName&quot;);
  var password = getElementById(&quot;passWord&quot;);
  
  
      function newPage() {
          if(username.val().length==0 || password.val().length==0){
              alert(&quot;please enter valid information&quot;);
              return location.href = &quot;newPage.html&quot;;
              }
              else{
                  location.href = &quot;newPage.html&quot;;
              }
          }
  </code></pre>
  <p>and here is my failed attempt to initialize my idea.</p>