I want to validate, but when I enter a number or a string in any case, the data type shows me a string and I can not validate correctly, please help me
function Validator() {
const x = document.getElementById("fname").value;
const a = typeof x === "string" && x.length >= 1;
console.log(typeof x);
if (a) {
console.log("type string");
} else {
console.log("other type");
};
}
<input id="fname">
<input type="submit" onclick="Validator()">