logo
Blog single photo

How to validate input field as an Alphabate using jquery


                        

<input id="full_name" name="full_name" >
<script>
$('#full_name').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');
            $('#full_name').val('');
            return false;
        }
    })

</script>

Top