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.