I created a JavaScript function to validate if a password is alphanumeric. However, I am facing an issue where the alert message is not being displayed when the password is not alphanumeric. Below is my code snippet:
if (!input_string.match(/^[0-9a-z]+$/)) {
alert("Please enter an alphanumeric password.");
}