Create registration form & apply validation controls

Create an employee registration form and apply all the validation controls.

Answer:

Introduction:
In this application we will use different validation controls so that the user can enter only valid records in the textbox. The RequiredFieldValidator control is used to make an input control a mandatory field.

It is a simple ASP page that performs all the validations on the textbox. If the user leaves the textbox blank, it throws the error message.

registration.aspx

<!DOCTYPE html>
  <script runat="server">

      Protected Sub dob_SelectionChanged(sender As Object, e As EventArgs)

      End Sub
  </script>
  <head>
       <title>Employee Registration Page</title>
  </head>
  <body>
      <form id="f1" method="post" runat="server">
          <fieldset style="width:280px; background-color:aqua">
              <table>                
                <tr>
                   <td>EmpName:</td><td> <asp:textbox id="txt1" runat="server" ></asp:textbox></td><td><font color="#cc0000">*</font></td>
                   <td> <asp:RequiredFieldValidator ID="validfname" runat="server" ControlToValidate="txt1" ErrorMessage="Required!" ForeColor="Red"></asp:RequiredFieldValidator></td>
               </tr>
               <tr>
                   <td>Password:</td><td><asp:textbox ID="pwd" runat="server" TextMode="Password"></asp:textbox></td><td><font color="#cc0000">*</font></td>
                   <td><asp:RequiredFieldValidator ID="validpwd" runat="server" ControlToValidate="pwd" ErrorMessage="Required!" ForeColor="Red"></asp:RequiredFieldValidator></td>
               </tr>
               <tr>
                   <td>ConPassword:</td><td><asp:textbox ID="cpwd" runat="server" TextMode="Password"></asp:textbox></td><td><font color="#cc0000">*</font></td>
                   <td><asp:RequiredFieldValidator ID="validcpwd" runat="server" ControlToValidate="cpwd" ErrorMessage="Required" ForeColor="Red"></asp:RequiredFieldValidator></td>
                </tr>
                <tr>
                    <td>EmailID:</td><td><asp:TextBox ID="email" runat="server" TextMode="Email" ></asp:TextBox></td><td><font color="#cc0000">*</font></td>
                    <td><asp:RequiredFieldValidator ID="validemail" runat="server" ControlToValidate="email" ErrorMessage="required!" ForeColor="Red"></asp:RequiredFieldValidator></td>
                </tr>
               <tr>
                    <td>DOB: </td><td><asp:TextBox ID="dob" runat="server"></asp:TextBox></td><td><font color="#cc0000">*</font> </td>
                    <td><asp:RequiredFieldValidator ID="validdob" runat="server" ControlToValidate="dob" ErrorMessage="Required" ForeColor="Red"></asp:RequiredFieldValidator></td>
                </tr>
                <tr>
                    <td>Address:</td><td><asp:TextBox ID="address" runat="server" TextMode="MultiLine" Rows="4" cols="21"></asp:TextBox></td><td><font color="#cc0000">*</font></td>
                    <td><asp:RequiredFieldValidator ID="validadd" runat="server" ControlToValidate="address" ErrorMessage="Required!" ForeColor="Red" ></asp:RequiredFieldValidator></td>
                </tr>
             <tr>
                    <td><asp:Button ID="btn1" runat="server" Text="Submit"></asp:Button></td>
                    <td><asp:Button ID="btn2" runat="server" Text="Cancel"></asp:Button></td>
                </tr>  
            </table>
         </fieldset>
      </form>
  </body>
</html>


Output:

employee registration