How do I add ASP.NET validation in C# all three text boxes aren’t empty and the phone number has the format of DDDD-DDDD where D is 0 – 9?
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
<asp:TextBox ID="txtPhoneNumber" runat="server"></asp:TextBox>
Have you tried to solve this problem yourself? The documentation is easy to find:
http://msdn.microsoft.com/en-us/library/aa479013.aspx
You need to use a required field validator — something like this:
You will also want a regular expression validator, something like:
NB The toolbox for reg expression has many built in, including most phone number formats. I would just use one of those.