Wednesday, March 6, 2013

Example using RequiredFieldValidator ,CompareValidator , RegularExpressionValidator in Registration From

 

Aspx Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RegistrationForm_withvalidations.aspx.cs" Inherits="Forum_Topics_RegistrationForm_withvalidations" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Enter Name:<asp:TextBox id="txtName" runat="server"></asp:TextBox>
    <br />
    <asp:RequiredFieldValidator ID="RFV1" runat="server" ControlToValidate="txtName" ErrorMessage="Name is must"></asp:RequiredFieldValidator>
    <br />
    Enter Password:
    <asp:TextBox ID="txtPwd" runat="server"></asp:TextBox>
    <br />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPwd" ErrorMessage="Password is must"></asp:RequiredFieldValidator>
    <br />
    Confirm Password:
    <asp:TextBox ID="txtConfirmPwd" runat="server"></asp:TextBox>
    <br />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtConfirmPwd" ErrorMessage="Confirm Password is must"></asp:RequiredFieldValidator>
    <br />
    <asp:CompareValidator ID="CV1" runat="server" ControlToValidate ="txtConfirmPwd" ControlToCompare ="txtPwd" ErrorMessage="Password and Confirm Password does not match">
    </asp:CompareValidator>
    <br />
     Enter Email - ID :<asp:TextBox ID="txtEmail" runat="server" MaxLength="50" Width="140px"></asp:TextBox>
     <br />
     <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtEmail" ErrorMessage="Email is must"></asp:RequiredFieldValidator>
     <br />
       <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
           ControlToValidate="txtEmail" ErrorMessage="*Invalid Email."
           ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
    <br />
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
    </div>
    </form>
</body>
</html>

Output :

Validator_op

validator_op1

2 comments:

  1. Please rate and review the app and
    Find your perfect date...
    https://play.google.com/store/apps/details?id=com.u2opia.woo

    ReplyDelete
  2. Really enjoy while reading, you have cover very small but important point, I am so impressed & appreciate your post.

    ReplyDelete