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

168
Views
Mobile Browser View Disable/Prevent entering white spaces inside input box using Javascript

The below code only working in web view, but not in mweb browser

onKeyPress={(e) => {
  var startPos = e.currentTarget.selectionStart;
  if (e.which === 32 && startPos == 0) {
      e.preventDefault();
  }
}

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

0

(function()
{
  let inp = document.querySelector('input');
  inp.addEventListener('keyup', function(e)
  {
    e.target.value = e.target.value.trimStart();
  });
})();
<input type="text">

If you try to put a space at the start of the text box then it will be removed. In fact any whitespace will.

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!