Letter Validation in JavaScript

There will be some scenarious where you want users to enter only letters like (A-Z or a-z), We can do letter only validations using JavaScript.

<script type='text/javascript'>
function letterValidation()
var letterValue = /^[a-zA-Z]+$/;
alert("Yes you enter letters only.");
return true;
alert('Enter only Letters like A-Z or a-z');
return false;
Please Letters Only: <input type='text' id='txtletter'/>
<input type='button' id="btnSubmit" onclick="letterValidation()" value='Submit' />

Leave a Reply

Your email address will not be published. Required fields are marked *