Make your web forms more secure by validating users input, like only allowing alphabets A to Z and numbers only, etc… Watch this tutorial to know how.
Here is the source code:
<!DOCTYPE html> <html> <head> <title>ZK Tutorials</title> </head> <body> <h1>JavaScript Text Input Validaton</h1> <p>Preventing users from inputting not allowed characters.</p> <input id="userInput" placeholder="type something"> <button onclick="validate()">Submit</button> <script> function validate(){ var userText = document.getElementById("userInput").value; var allowedCharacters = /^[a-zA-Z0-9]+$/; if(userText.match(allowedCharacters)) alert("Input OK"); else alert("Input Error!"); } </script> </body> </html>
loading...