Regular expression to validate a firstname or a lastname

need to fix the regular expression for last name

                                                      <td class="physicalLightBox" align="left">
                                                      <div class="label">
                                                            <img height="14" src="images/starsmallfull.gif" width="15" />&nbsp;Last Name</div>
                                                      <td class="physicalLightBox" style="text-align: left;">
                                                      &nbsp;<asp:TextBox ID="txtLastName" MaxLength="50" runat="server" Width="155px" BorderStyle="Inset" BorderWidth="2px" BorderColor="DarkGray" />
            <asp:RequiredFieldValidator ID="RFVtxtLastName" runat="server"  ControlToValidate="txtLastName" ErrorMessage="<b>Required Field Missing.</b><br />Last Name is required." Font-Size="X-Small" SetFocusOnError="true" Display="None"></asp:RequiredFieldValidator>
            <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="RFVtxtLastNameE" TargetControlID="RFVtxtLastName" HighlightCssClass="validatorCalloutHighlight" />    
            <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender16" runat="server"
             <asp:RegularExpressionValidator ID="REVtxtLastName" runat="server" ControlToValidate="txtLastName" Font-Size="X-Small" SetFocusOnError="true" ValidationExpression="^[A-Z]{1}[a-zA-Z]{1,}$" ErrorMessage="<b>A valid Last Name name is required,</b><br />Please type between 2 to 75 letters<br />(avoid special characters and digits)" Display="None"></asp:RegularExpressionValidator>
             <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="REVtxtLastNameE" TargetControlID="REVtxtLastName" HighlightCssClass="validatorCalloutHighlight" />
         <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender18" runat="server"
Who is Participating?
Kevin CrossConnect With a Mentor Chief Technology OfficerCommented:

This is requiring first letter to be uppercase and then one or more letters that can be lower or uppercase.  If you don't care about case, then try this.


Added upper bound as well since you are indicating only 75 characters max.
Kevin CrossChief Technology OfficerCommented:
>>need to fix the regular expression for last name

What is it doing OR not doing?
mathieu_cuprykAuthor Commented:
the message is coming up when I enter for example cupryk

Please type between 2 to 75 letters<br />(avoid special characters and digits)"
the above message.
mathieu_cuprykAuthor Commented:
i have aproblem with the postal codes
iam posting anew question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.