Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
How to detected forbidden letters in a variable that comes from html in javascript?

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!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change var fname = document.getElementById("fname_id").value; to this var fname = document.getElementById("fname_id").innerText;

HTMLElement object has no value property.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!