Regular expression to validate a firstname or a lastname

need to fix the regular expression for last name

<tr>
                                                      <td class="physicalLightBox" align="left">
                                                      <div class="label">
                                                            <img height="14" src="images/starsmallfull.gif" width="15" />&nbsp;Last Name</div>
                                                      </td>
                                                      <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"
            TargetControlID="RFVtxtLastName">
            </ajaxToolkit:ValidatorCalloutExtender>
       
             <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"
            TargetControlID="REVtxtLastName">
        </ajaxToolkit:ValidatorCalloutExtender>
                                                     </td>
                                                </tr>
mathieu_cuprykAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin CrossChief Technology OfficerCommented:
>>need to fix the regular expression for last name

What is it doing OR not doing?
0
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.
0
Kevin CrossChief Technology OfficerCommented:
="^[A-Z]{1}[a-zA-Z]{1,}$"

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.

="^[a-zA-Z]{1}[a-zA-Z]{1,74}$"

Added upper bound as well since you are indicating only 75 characters max.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mathieu_cuprykAuthor Commented:
i have aproblem with the postal codes
iam posting anew question.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.