0

good day people. I am trying to create a password validation before form submission using javascript and jquery When the submit button is clicked I want it to validate password. If password is not set, it will alert that password has not been entered. otherwise display success message and submit form.

Here is my javascript:

<html>

<head>

  <script type="text/javascript" src="https://jinji.jinjer.biz/assets/templates/hr/js/jquery.min.js"></script>
</head>

<body>
  <form method="post" id="login-form" target="dummyframe" action="https://kintai.jinjer.biz/v1/sign_in">


    <input name="company_code" type="hidden" value="5709" />

    <input name="email" type="hidden" value="5685" />

    <input class="jpassword" name="password" type="password" />
    <input value="LogIn" class="submit" /><br><br>

  </form>

  <script>
    $(document).ready(function() {
      $(function() {
        $(".submit").on('click', function() {
          var password = document.getElementByClassName("jpassword");
          if (password.val = "") {
            alert("Please Enter password");
            else {
              alert("Success. Now you can login");
              document.getElementById("login-form").submit();
            }
          }

        });

      });
    });
  </script>
</body>

</html>

My code doesnt work. Am i missing something? You help would be greatly appreciated.

charlietfl
  • 170,828
  • 13
  • 121
  • 150
Rav
  • 15
  • 5

0 Answers0