Hey rakibxl,
Please refer below sample.
HTML
<div>
<asp:TextBox runat="server" ID="txtId" />
<asp:Button Text="Check" runat="server" OnClick="Check" />
</div>
Namespaces
C#
using System.Text.RegularExpressions;
VB.Net
Imports System.Text.RegularExpressions
Code
C#
protected void Check(object sender, EventArgs e)
{
Regex pattern = new Regex(@"^[I-T]");
if (!pattern.IsMatch(txtId.Text))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('input must Start with IT.');", true);
}
}
VB.Net
Protected Sub Check(ByVal sender As Object, ByVal e As EventArgs)
Dim pattern As Regex = New Regex("^[I-T]")
If Not pattern.IsMatch(txtId.Text) Then
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Message", "alert('input must Start with IT.');", True)
End If
End Sub
Screenshot