WEBFORM .ASPX CODE
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="comparefieldvalid.aspx.cs" Inherits="WebApplication13.comparefieldvalid" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 159px;
}
.auto-style3 {
width: 159px;
height: 31px;
}
.auto-style4 {
height: 31px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Label ID="Label1" runat="server" Text="Email"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Width="233px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Email Format" ControlToValidate="TextBox1" Display="Dynamic" ForeColor="#CC0000" ValidationExpression="^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="Email is Reuqired" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style3">
<asp:Label ID="Label2" runat="server" Text="Re type Email"></asp:Label>
</td>
<td class="auto-style4">
<asp:TextBox ID="TextBox2" runat="server" Width="233px"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="Email doesnot Match" ForeColor="#CC0000" Display="Dynamic"></asp:CompareValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" Display="Dynamic" ErrorMessage="Retype Email is Reuqired" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</td>
<td class="auto-style4"></td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3" runat="server" Text="Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server" Width="233px" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox3" Display="Dynamic" ErrorMessage="Passowrd is Reuqired" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label4" runat="server" Text="Confirm Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox4" runat="server" Width="233px" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox4" Display="Dynamic" ErrorMessage="Retpye Passowrd is Reuqired" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</td>
<td> </td>
</tr>
</table>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
</form>
</body>
</html>
WEBFORM .ASPX.CS CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication13
{
public partial class comparefieldvalid : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Response.Write("Email approved");
}
}
}
}
WEB.CONFIG CODE
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
No comments:
Post a Comment