0% found this document useful (0 votes)
8 views4 pages

Registration Form Validation Example

This document contains an ASP.NET registration form with validation controls to validate user input. RequiredFieldValidators are used to validate that the email, username, password, and retyped password fields are filled out. A RegularExpressionValidator validates the email format. A CompareValidator ensures the password and retyped password match. A ValidationSummary control displays any validation errors.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Registration Form Validation Example

This document contains an ASP.NET registration form with validation controls to validate user input. RequiredFieldValidators are used to validate that the email, username, password, and retyped password fields are filled out. A RegularExpressionValidator validates the email format. A CompareValidator ensures the password and retyped password match. A ValidationSummary control displays any validation errors.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Summary Validation Example

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"


Inherits="[Link]" %>

<!DOCTYPE html>

<html xmlns="[Link]
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 697px;
}

.auto-style2 {
width: 123px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="border: 1px solid gray; width: 400px">
<table border="0" class="auto-style1">
<tr>
<td colspan="2">
<h3 style="text-align:
left;">Registration Form</h3>
</td>
</tr>
<tr>
<td class="auto-style2">
<b>Email</b>
</td>
<td>
<asp:TextBox ID="txtEmail"
runat="server" Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Email Filed Is
Required!"
ControlToValidate="txtEmail"
ForeColor="Red"
Display="Dynamic">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ErrorMessage="Invalid Email!"
ForeColor="Red"
ControlToValidate="txtEmail"
ValidationExpression="\w+([-
+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Display="Dynamic">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<b>UserName</b>
</td>
<td>
<asp:TextBox ID="txtUserName"
runat="server" Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server"
ErrorMessage="User Name Filed Is
Required!"
ControlToValidate="txtUserName"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<b>Password</b>
</td>
<td>
<asp:TextBox ID="txtPassword"
runat="server" Width="150px"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator3" runat="server"
ErrorMessage="Password Filed Is
Required!"
ControlToValidate="txtPassword"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<b>Retype Password</b>
</td>
<td>
<asp:TextBox ID="txtRetypePassword"
runat="server" Width="150px"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator4" runat="server"
ErrorMessage="Retype Password
Filed Is Required!"

ControlToValidate="txtRetypePassword" ForeColor="Red"
Display="Dynamic">*</asp:RequiredFieldValidator>
<asp:CompareValidator
ID="CompareValidator1" runat="server"
ErrorMessage="Password and
Confrim Password Does Not Match!" ForeColor="Red"

ControlToValidate="txtRetypePassword"
ControlToCompare="txtPassword"
Type="String" Operator="Equal"
Display="Dynamic">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnSave"
runat="server" Text="Save" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:ValidationSummary
ID="ValidationSummary1" runat="server" ForeColor="Red"
HeaderText="Validation Errors" ShowMessageBox="True" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblStatus"
runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

You might also like