Required Field Validator In ASP.NET Web Forms | Form Validation In Web Forms

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VALIDATION_FORM.aspx.cs" Inherits="VALIDATION_CONTROLS.VALIDATION_FORM" %>


<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

    <style type="text/css">

        .auto-style1 {

            width: 71%;

            margin-right: 0px;

        }

        .auto-style2 {

            width: 223px;

        }

    </style>

</head>

<body>

    <form id="form1" runat="server">

        <div>

            <h2>STUDENTS REGISTRATION FORM</h2>

            

            <br />

            <table class="auto-style1">

                <tr>

                    <td class="auto-style2">STUDENT NAME</td>

                    <td>

                        <asp:TextBox ID="NamesTextBox" runat="server" Width="197px"></asp:TextBox>

                        <asp:RequiredFieldValidator ID="NameTextBox" runat="server" ControlToValidate="NamesTextBox" ErrorMessage="Please Enter Name" ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>

                    </td>

                </tr>

                <tr>

                    <td class="auto-style2">STUDENT EMAIL</td>

                    <td>

                        <asp:TextBox ID="EmailTextBox" runat="server" Width="197px"></asp:TextBox>

                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="EmailTextBox" ErrorMessage="Please Enter Email" ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>

                    </td>

                </tr>

                <tr>

                    <td class="auto-style2">RE-ENTER EMAIL&nbsp;</td>

                    <td>

                        <asp:TextBox ID="ReEnterEmailTextBox" runat="server" Width="197px"></asp:TextBox>

                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ReEnterEmailTextBox" ErrorMessage="Please Re-Enter Email" ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>

                    </td>

                </tr>

                <tr>

                    <td class="auto-style2">&nbsp;</td>

                    <td>

                        <asp:Button ID="Button1" runat="server" Height="36px" Text="SUBMIT" Width="98px" />

                    </td>

                </tr>

            </table>

            

        </div>

    </form>

</body>

</html>

Above File is VALIDATION_CONTROLS\VALIDATION_FORM.aspx



Comments

Popular posts from this blog

Range Validator Control In ASP.NET Web forms | Form Validation | ASP.NET Web forms

Query String In ASP.NET Web Forms | State Management | ASP.NET | Web Forms

Validation Summary Control In ASP.NET Web forms | Form Validation | ASP.NET