Regular Expression to accept specific Alphabets (ABCD) in TextBox in ASP.Net

Hariom
 
on Oct 16, 2019 03:30 AM
Sample_148065.zip
2247 Views

Hello,

How can i validate textbox control only for four letters, A,B,C,D

No one can enter any text without these letters.

thank you

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Oct 16, 2019 03:33 AM

Hi Hariom,

Use RegularExpression Validator.

Check this example. Now please take its reference and correct your code.

HTML

<asp:TextBox ID="TextBox1" runat="server" /><br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
    ForeColor="Red" ValidationExpression="[ABCD]*$" ErrorMessage="*Valid characters: A,B,C,D." /><br />
<asp:Button ID="Button1" Text="Validate" runat="server" />

Screenshot