acutally my english is not good but i want to detect forbidden letters in a variable that comes from html input but its not working. My code:
nextBtnFirst.addEventListener("click", function(event) {
event.preventDefault();
//Validating the required Fields//
var fname = document.getElementById("fname_id").value;
var lname = document.getElementById("lname_id").value;
var letters = "/^[0-9a-zA-Z]+$/";
if(fname =="" || lname=="") {
updateError("First name and Last name is required!");
} else {
slidePage.style.marginLeft = "-25%";
bullet[current - 1].classList.add("active");
progressCheck[current - 1].classList.add("active");
progressText[current - 1].classList.add("active");
current += 1;
}
});
What i have tried but didnt work:
if(fname.includes("!")) {
updateError("Dont use forbidden Characters!");
}
Please help. Thanks!
Change
var fname = document.getElementById("fname_id").value; to this
var fname = document.getElementById("fname_id").innerText;
HTMLElement object has no value property.