JezK
Edit File: changepassword.php
<?php include("header.php"); ?> <style> .quantity::-webkit-inner-spin-button, .quantity::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; } .changeflex { display: flex; flex-direction: column; align-items: center; } .text-align { text-align:center; } </style> <section class="dashboard-counts section-padding"> <div class="container-fluid bg-white px-5 py-3"> <div class="row bg-white"> <form class="form-horizontal col-sm-12 h-100" action="change-password-app.php" method="POST" onsubmit="return validateForm()"> <div class="form-group"> <div class="row changeflex"> <div class="col-xl-6 col-sm-6 col-lg-6 text-align"> <h2>Change Password</h2> </div> <div class="col-xl-6 col-sm-6 col-lg-6"> <label for="oldPassword" class="fieldName">Old Password</label> <input type="password" maxlength="30" class="form-control formField-control quantity" name="oldPassword" id="oldPassword" autofocus required onkeypress="return checkSpace(event)" onpaste="return false"> </div> <div class="col-xl-6 col-sm-6 col-lg-6"> <label for="newPassword" class="fieldName">New Password</label> <input type="password" maxlength="30" class="form-control formField-control quantity" name="newPassword" id="newPassword" required onkeypress="return checkSpace(event)" onpaste="return false"> </div> <div class="col-xl-6 col-sm-6 col-lg-6"> <label for="confirmPassword" class="fieldName">Confirm Password</label> <input type="password" maxlength="30" class="form-control formField-control quantity" name="confirmPassword" id="confirmPassword" required onkeypress="return checkSpace(event)" onpaste="return false"> </div> <div class="col-xl-6"> <label for="username" class="fieldName invisible">Change Password</label> <button class="btn btn-primary w-100" onclick="return addPercentage();">Change Password</button> </div> </div> <div class="row"> </div> </div> </form> </div> </div> </section> <script> function checkSpace(e) { var key = e.keyCode if(key == 32) { alert("Space is not allowed in the password"); return false; } return true; } function validateForm() { var newPassword = document.getElementById('newPassword'); var confirmPassword = document.getElementById('confirmPassword'); var oldPassword = document.getElementById('oldPassword'); if(oldPassword.value.trim().length == 0) { alert('Password must not be empty.'); oldPassword.value = ""; newPassword.value = ""; confirmPassword.value = ""; oldPassword.focus(); return false; } if(newPassword.value.trim().length == 0 || confirmPassword.value.trim().length == 0) { alert('Password must not be empty.'); newPassword.value = ""; confirmPassword.value = ""; newPassword.focus(); return false; } if(newPassword.value.trim().length < 6 || confirmPassword.value.trim().length < 6) { alert('Password must be minimum 6 characters.'); newPassword.value = ""; confirmPassword.value = ""; newPassword.focus(); return false; } if(confirmPassword.value != newPassword.value) { alert('Password mismatch.'); newPassword.value = ""; confirmPassword.value = ""; newPassword.focus(); return false; } return true; } </script> <?php include("footer.php");?>