Validation for CNIC number using jQuery in ASP.Net

Last Reply one year ago By AnandM

Posted one year ago

how to accept alphabets only in textbox in asp

Posted one year ago

Hi AhmadCh,

Refer the below article.

Regular Expression (Regex) to accept only Alphabets and Space in TextBox in ASP.Net

Also i have created a sample which fullfill your requirement

HTML

<div>
    <input type="text" name="name" id="txtName" />
    <input type="button" value="Submit" id="btnSubmit" name="Submit" />
</div>
<div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('[id*=btnSubmit]').click(function () {
                var regex = /^[A-Za-z ]+$/;
                if (!regex.test($('[id*=txtName]').val())) {
                    alert('Please Enter Only Alphabets');
                    $('[id*=txtName]').val('');
                }
            });
        });
    
    </script>
</div>

Demo


Posted one year ago Modified on one year ago

Hi AhmadCh,

Please refer below sample 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.0/jquery.mask.min.js"
        type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('[id*=txtRic]').mask('00000-0000000-0');
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="text" name="txtRic" id="txtRic" />
    </div>
    </form>
</body>
</html>

Demo

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html