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

102
Views
Is there a way to detect if a user has not answered an input?

I am making a name picker and I want to detect if your user has input a name or if they are just messing with the website. Is there a way to do this? Code:

<html>
<textarea id="names"></textarea>
<input type="submit" value="Pick" onclick="onClick(this)">
<p id="chosen"></p>
</html>
<script>
function onClick(x) {
//Your code
}
</script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The getNames() method is called for the <input> element to check for value when it submits, and a value is returned after the value inside the <textarea> element is checked.

/* This helper method checks whether the login has been made or not. */
function isNameEmpty(){
   var name = document.getElementById("names");
   
   if(name.value.length != 0){
      console.log(name.value);
      return false;
   }
   else{
      console.log('No value was entered.');
      return true;
   }
}

/* This submit method is used to return the entered name. */
function getNames(){
  if(!isNameEmpty()){
    return document.getElementById("names").value;
  }
  else{
    alert('No value was entered.');
    return '';
  }
}
<textarea id="names"></textarea>
<input type="submit" value="Pick" onclick="return getNames();">
<p id="chosen"></p>


References
  • Add onclick function to a submit button
about 4 years ago · Juan Pablo Isaza Report

0

you can change the textarea to input tag and you can use browser built in attributes like type= text min max length etc.

otherwise you should write a function that reads and evaluates the input value of the textarea

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!