$('#textName').keypress(function (e) { var regex = new RegExp("^[a-zA-Z]+$"); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } else { e.preventDefault(); alert('Please Enter Alphabate'); return false; } });
^[a-zA-Z\s]+$
txtName
<input type="text" name="name" id="txtName"></input>
$('#textName').keypress(function (e) {
$('#txtName').keypress(function (e) {
/^[a-zA-Z\s]+$/
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)