I have a textbox,I want to validate it to contain alphabets and hypen and dot for Inserting name..
ex for:Dr. HAMID-ULLAL
@Html.TextBoxFor(m => m.FirstName, new { @class = "form-control validate[required,custom[onlyLetterSQ]]", @id = "firstName" })
Here I have created sample that full-fill your requirement using RegularExpressionValidatior.
HTML
<div> Name : <asp:TextBox ID="txtName" runat="server" /> <asp:RegularExpressionValidator runat="server" ControlToValidate="txtName" ValidationExpression="^([a-zA-Z]+)[.]\s?([a-zA-Z]+)[-]([a-zA-Z]+)$" ErrorMessage="Invalid Name Format" ForeColor="Red"></asp:RegularExpressionValidator> </div>
Screenshot
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.