alphanumeric validation JavaScript JS

Alphanumeric validation in JavaScript is used to make sure that all the characters entered in the specified field must be any alphabet (A-Z or a-z) or any number (0-9).

Regular Expression:



<!DOCTYPE html>
<html lang="en">
function lettersNumbersCheck(name)
var regEx = /^[0-9a-zA-Z]+$/;
return true;
alert("Please enter letters and numbers only.");
return false;
<div class="mail">
<h2>JavaScript Letters Numbers Validation</h2>
<form name="form1" action="#">
Name: <input type='text' name='name'/></br></br>
<input type="submit" name="submit" value="Submit" onclick="lettersNumbersCheck("/>
Please follow and like us:
Content Protection by