title: Form Validation event.preventdefault not working
body: <p>I am new to Javascript &amp; Jquery. I am currently working on college project, I have a form input control for new password change and I want to avoid submitting the form if the use have not entered anything. I am not sure if I have chained the method well or if it is a correct to match the value from the two input fields.
  I know there is a validation plugin but I want to try work things out before that. </p>
  
  <p>Any help or suggestion will be appreciated</p>
  
  <p>Here is the code</p>
  
  <pre><code>&lt;form id="accmanager" name="accmanager" action="view-acc.php" method="POST"&gt;
      &lt;h1&gt;Account Management&lt;/h1&gt;
      &lt;p&gt;
        &lt;ul type="none"&gt;
          &lt;li&gt;&lt;input type="radio" name="optaccmanager" checked="checked" id="viewaccinfo" /&gt; View Account Information&lt;/li&gt;
          &lt;li&gt;&lt;input type="radio" name="optaccmanager" id="addacc" /&gt; Add Account&lt;/li&gt;
          &lt;li&gt;&lt;input type="radio" name="optaccmanager" id="tochangepass" /&gt; Change Password
           &lt;ul id="changepass" type="none" style="display: none"&gt;
              &lt;li&gt;&lt;input type="text" name="newpassword" id="newpassword" size="23" title="Enter new password" /&gt;&lt;/li&gt;
              &lt;li&gt;&lt;input type="text" name="confirmpassword" id="confirmpassword" size="23" title="Re-type new password" /&gt;&lt;/li&gt;
          &lt;/ul&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
      &lt;input id="submitbtn" type="submit" value="View Account" style="display: inline-block;position: absolute;left: 5em;top:20em;" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and the script code</p>
  
  <pre><code>&lt;script&gt;
      //form validation section
      $(document).ready(function(){
          var changepass = $("#changepass"),
              addacc = $("#addacc"),
              viewaccinfo = $("#viewaccinfo"),
              tochangepass = $("#tochangepass");
  
              addacc.on("click",function(event){
                changepass.css("display","none");
                $("#submitbtn").attr("value","Add Account");
              });
  
              viewaccinfo.on("click",function(event){
                  changepass.css("display","none");
                  $("#submitbtn").attr("value","View Account");
              });
  
              tochangepass.on("click",function(event){
                  changepass.css("display","inline");
                  $("#submitbtn").attr("value","Change Password");    
              });
  
              $("form").submit(function(event){
                  var newpassword = $("#newpassword"),
                      confirmpassword = $("#confirmpassword");
  
                  if ((newpassword.val == null) || (confirmpassword.val == null)) {
                      event.preventDefault;
                      newpassword.attr("title","Please enter new password");
                  }
              });
     });
  </code></pre>