0% found this document useful (0 votes)
18 views

Ass2 Asp

The document contains code for an ASP.NET validation form with fields for roll number, name, address, contact number, and email. It uses required field and regular expression validators to validate the user input.

Uploaded by

Dhruv Jadvani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Ass2 Asp

The document contains code for an ASP.NET validation form with fields for roll number, name, address, contact number, and email. It uses required field and regular expression validators to validate the user input.

Uploaded by

Dhruv Jadvani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Mehul patel

Roll no: 35
ASSIGNMENT 2 Sub: Asp.net

Q.2 Create a Validation Form Example

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb"


Inherits="validation._Default" %>

<!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>
<style type="text/css">
.style1
{
width: 541px;
}
.style2
{
width: 235px;
}
.style3
{
width: 499px;
}
.style4
{
height: 65px;
}
.style5
{
width: 263px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table align="center" style="height: 109px; width: 841px" >
<tr>
<td colspan="4" align="center" class="style4"
style="font-size: 31px; font-weight: bold;" > Validation Form </td>
</tr>

<tr>
<td class="style2">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-
Size="13pt"
Text="Roll-no :-"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="TextBox1" runat="server" Height="36px"
Width="237px"></asp:TextBox>
</td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="Pls Enter
name"></asp:RequiredFieldValidator>
</td>
<td class="style3">
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="&lt; 150" Font-
Size="15pt"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-
Size="13pt"
Text="Name :-"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="TextBox2" runat="server" Height="36px"
Width="232px"></asp:TextBox>
</td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="TextBox2" ErrorMessage="Please Enter
name"></asp:RequiredFieldValidator>
</td>
<td class="style3">
</td>

</tr>
<tr>
<td class="style2">
<asp:Label ID="Label3" runat="server" Font-Bold="True" Font-
Size="13pt"
Text="Address :-"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="TextBox6" runat="server" Height="34px"
Width="231px"></asp:TextBox>
</td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server"
ControlToValidate="TextBox6" ErrorMessage="Please Enter
Address"></asp:RequiredFieldValidator>
</td>
<td class="style3">
&nbsp;</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label4" runat="server" Font-Bold="True" Font-
Size="13pt"
Text="Contact no :-"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="TextBox4" runat="server" Height="36px" Width="49px"
Font-Bold="True" Font-Size="13pt">+91</asp:TextBox>
<asp:TextBox ID="TextBox7" runat="server" Height="35px"
Width="177px"></asp:TextBox>
</td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server"
ControlToValidate="TextBox7" ErrorMessage="Pls Enter
Number"></asp:RequiredFieldValidator>
</td>
<td class="style3">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox7" ErrorMessage="Pls Enter Valid
Number"
Font-Size="13pt" ValidationExpression="(\(\d{3}\)|\d{3}-
)?\d{10}"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label5" runat="server" Font-Bold="True" Font-
Size="13pt"
Text="E-mail :-"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="TextBox5" runat="server" Height="36px"
Width="227px"></asp:TextBox>
</td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server"
ControlToValidate="TextBox5" ErrorMessage="Pls Enter E-
mail"></asp:RequiredFieldValidator>
</td>
<td class="style3">

<asp:RegularExpressionValidator ID="RegularExpressionValidator2"
runat="server"
ControlToValidate="TextBox5" ErrorMessage="Pls Enter Valid E-
mail"
Font-Size="13pt"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
</td>

</tr>

<tr>
<td colspan="4" align="center">
<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-
Size="15pt"
Text="OK" Height="55px" Width="125px" />
</td>

</tr>
</table>
</form>
</body>
</html>

</body>
</html>

Output :-

You might also like