I need help debugging my code. It does everything I need it to do but for the UID, the criteria needs to be that the UID can only be valid if the text entered has an uppercase letter, lowercase letter, and a number and is between 8 to 12 charaacters long. Right now it will give me a valid response if I either have all lowewrcase letters and a number, or all uppercase letters with a number. It will also give me a valid response for uppercase, lowercase and a number which is what I want, but that is not the only way it will produce a valid response I need it to show invalid if there are all lowercase letters and a number and also invalid if all the characters are all uppercase and has a number as well.
<html>
<body>
<div>
<!-- <put your HTML code to input data here> -->
User Id: <input type="text" id="uid"><br>
First Name: <input type="text" id="fname"><br>
Last Name: <input type="text" id="lname"><br>
Birthday: <input type="date" id="bday"> <br>
<button id="press_accept" onclick="verify()">Accept</button><br>
</div>
<!-- result div to display the result -->
<div id="result">
</div>
<script>
// put your JavaScript code to read HTML inputs
// and validate inputs here using if statements
function verify() {
// get the result element
const result = document.getElementById('result');
// get the user id
const uid = document.getElementById("uid").value;
// if the length of user id is between 8 to 12
if(uid.length >= 8 && uid.length <= 12){
let upper = false;
let lower = false;
let number = false;
// iterate over each letter of the user id
for(let i=0;i<uid.length;i++){
let char = uid[i];
// if the letter is an uppercase letter
if(char === char.toUpperCase()){
upper = true;
}
// if the letter is a lowercase letter
if(char === char.toLowerCase()){
lower = true;
}
// if the letter is a number
if(Number.isNaN(parseInt(char))){
number = true;
}
}
// if user id is invalid
if(!(upper && lower && number)){
result.innerHTML = 'Invalid UserID';
return;
}
}
else{
result.innerHTML = 'Invalid UserID';
return;
}
// get first name and check its validity
const fname = document.getElementById("fname").value;
if (fname === '') {
result.innerHTML = 'Invalid fname';
return;
}
// get last name and check its validity
const lname = document.getElementById("lname").value;
if (lname === '') {
result.innerHTML = 'Invalid lname';
return;
}
// get birthdate and check its validity
const bday = document.getElementById("bday").value;
if (bday === '') {
result.innerHTML = 'Invalid Birthday';
return;
}
}
</script>
</body>
</html>