Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

Only numbers and letters are allowed

Hi experts, I'm looking for some codes who will disallow or detect any symbols in an input text. I want that in the input text, only numbers or letters is in there, that whenever there's a presence of any of them an alert message will pop-up. Any help please!  

<!DOCTYPE html>
<html>

<body>

<input id="idno" type="text"/>

<button onclick="OnlyWordsAndNumbers(document.getElementById('idno'))">Check</button>

<script>
function OnlyWordsAndNumbers(el) 
{
  //If el is compose of any symbols like @ # ? ! and many others then an alert woulb be..
  //Only letters and numbers are allowed in the box.
}
</script>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Whing Dela Cruz

ASKER

Thank you Bill, Its working very well!
Avatar of Bill Prew
Bill Prew

Welcome, glad that helped.


»bp