You need input validation in your forms to keep your application secure. The best and easiest way to implement input validation is that using regular expressions (regex).
Here is a simple regex to make sure that only English alphabet is allowed in the text field for user’s first name:
<telerik:RadTextBox ID="txtFirstName" runat="server" Font-Size="Medium" Width="200px"></telerik:RadTextBox><span class="mandotaryField" title="Mandotary field"> *</span> <asp:RegularExpressionValidator ID="regexFirstName" CssClass="ValidationMessage" SetFocusOnError="true" runat="server" Display="Dynamic" ValidationExpression="^[a-zA-Z]$" ControlToValidate="txtFirstName" ErrorMessage="Invalid name format"></asp:RegularExpressionValidator>
What if you want to allow more than English alphabet? Let’s say you have users from Europe so that you need your regex to accept European languages such as German, Italian, Spanish, Portuguese, Danish, Swedish, Irish, Albanian and more.
Use this regex to accept over 70 European (and some African) characters in your text field:
^[a-zA-Z\u00c0-\u017e]$
Here are the characters accepted by this regex:
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿıŒœŠšŸŽž
More Information:
no ė in Lithuanian 🙁
ė in Lithuanian is U0116 (Capital) and U0117 (lower case) – so it is matched by the range of u00c0-u017e