Registration form with validation
Registration form with validation
---------------------
Aspx Designing
---------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Details.aspx.cs" Inherits="Details" %>
<!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>
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" />
<script src="jquery-3.3.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
/*code: 48-57 Numbers
8 - Backspace,
35 - home key, 36 - End key
37-40: Arrow keys, 46 - Delete key*/
function restrictAlphabets(e) {
var x = e.which || e.keycode;
if ((x >= 48 && x <= 57) || x == 8 ||
(x >= 35 && x <= 40) || x == 46)
return true;
else
return false;
}
function btnSubmit_onclick() {
}
</script>
<style type="text/css">
.style1
{
height: 26px;
}
.style2
{
width: 180px;
}
.style3
{
height: 26px;
width: 180px;
}
</style>
</head>
<body style="text-align:right;">
<h1 style="padding-right:300px; color:#ace02a; font-size:50px; text-shadow: 1px 1px 2px black, 0 0 25px white, 0 0 5px black;">Farm to Door</h1>
<div align="right">
<form id="form1" runat="server">
<div>
<table class="con">
<tr>
<td>Customer Name</td>
<td class="style2">
<asp:TextBox ID="TextBox1" runat="server" Width="181px" Height="20px"
BorderColor="#ACE02A" ForeColor="Black"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Enter a name" ControlToValidate="TextBox1" ForeColor="Red"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Mobile No</td>
<td class="style2"> <asp:TextBox ID="TextBox2" runat="server"
onkeypress='return restrictAlphabets(event)' MinLength="10" MaxLength="10"
Width="181px" Height="20px" BorderColor="#ACE02A" ForeColor="Black"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="Enter a Mobile Number" ControlToValidate="TextBox2"
ForeColor="Red"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Alternate Mobile No</td>
<td>
<asp:TextBox ID="TextBox9" runat="server"
onkeypress='return restrictAlphabets(event)' MinLength="10" MaxLength="10"
Height="20px" Width="181px" BorderColor="#ACE02A"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>E-mail</td>
<td class="style2">
<asp:TextBox ID="TextBox4" runat="server" Width="181px" Height="20px"
BorderColor="#ACE02A"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ErrorMessage="Enter Valid Email" ControlToValidate="TextBox4"
ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ErrorMessage="Enter Email ID" ControlToValidate="TextBox4" ForeColor="Red"
Display="Dynamic"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Quantity</td>
<td class="style2">
<asp:DropDownList ID="DropDownList1" runat="server" Width="184px"
AutoPostBack="false" Height="25px" BackColor="#ACE02A">
<asp:ListItem Text="Select" Value="Select" Selected="True"></asp:ListItem>
<asp:ListItem Text="2KG" Value="2KG"></asp:ListItem>
<asp:ListItem Text="5KG" Value="5KG"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ErrorMessage="Enter Valid Quantity" ForeColor="Red"
ControlToValidate="DropDownList1" InitialValue="Select"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>City</td>
<td class="style2">
<asp:DropDownList ID="DropDownList3" runat="server" Height="25px" Width="184px"
BackColor="#ACE02A" >
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem>Mumbai</asp:ListItem>
<asp:ListItem>Thane</asp:ListItem>
<asp:ListItem>Navi-Mumbai</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ErrorMessage="City Required" ControlToValidate="DropDownList3"
ForeColor="Red" InitialValue="Select"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Street Line 1</td>
<td>
<asp:TextBox ID="TextBox6" runat="server" Height="20px" Width="181px" BorderColor="#ACE02A"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
ControlToValidate="TextBox6" ErrorMessage="Value Required" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
<tr>
<td>Street Line 2</td>
<td>
<asp:TextBox ID="TextBox7" runat="server" Height="20px" Width="181px" BorderColor="#ACE02A"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"
ControlToValidate="TextBox7" ErrorMessage="Value Required" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Pin-Code</td>
<td>
<asp:TextBox ID="TextBox8" runat="server"
onkeypress='return restrictAlphabets(event)' Height="20px" Width="181px"
MaxLength="6" MinLength="6" ToolTip="Amount 100" BorderColor="#ACE02A"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server"
ControlToValidate="TextBox8" ErrorMessage="Value Required" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
</tr>
<tr>
<td class="style1">Type</td>
<td class="style3">
<asp:DropDownList ID="DropDownList2" runat="server" Width="184px"
AppendDataBoundItems="true" Height="25px" BackColor="#ACE02A">
<asp:ListItem Text="Select" Value="Select" Selected="True"></asp:ListItem>
<asp:ListItem Text="Green" Value="Green"></asp:ListItem>
<asp:ListItem Text="Black" Value="Black"></asp:ListItem>
<asp:ListItem>Combo (Green/Black)</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ErrorMessage="Select Valid Type" ControlToValidate="DropDownList2"
ForeColor="Red" InitialValue="Select"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Remark</td>
<td class="style2">
<asp:TextBox ID="TextBox5" runat="server" TextMode="MultiLine" Width="181px" Height="30px" BorderColor="#ACE02A"></asp:TextBox></td>
<td>
</td>
</tr>
<tr>
<td colspan="3">
<asp:CheckBox ID="chkbox" runat="server" Text="I'm interested in booking as per ETI Terms Condition and i'm ready to pay advance 100Rs"
style="font-size: 14pt" AutoPostBack="True" oncheckedchanged="chkbox_CheckedChanged" ForeColor="#44DD11" />
<tr>
<td>
</td>
<td>
</td>
<td>
<asp:Button ID="btnclick0" runat="server" Text="Submit"
Height="40px" Width="85px" onclick="Button1_Click" BorderColor="Black"
ForeColor="Black" BackColor="White" Font-Bold="True" Font-Names="Segoe UI"
Font-Overline="False" Font-Size="Large" Font-Strikeout="False"
Font-Underline="False" BorderStyle="Solid" />
</td>
</td>
</tr>
</table>
</div>
</form>
</div>
</body>
</html>
--------------
Aspx.cs
--------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Threading.Tasks;
using System.Web.Script;
public partial class Details : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Your Data Source");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into Final_Table3 values('"+DateTime.Now+"','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox9.Text + "','" + TextBox4.Text + "','" + DropDownList1.Text + "','" + DropDownList3.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + DropDownList2.Text + "','" + TextBox5.Text + "')";
cmd.ExecuteNonQuery();
con.Close();
//MessageBox.Show("Data inserted succesfully");
Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Transaction Succesfully Completed Paytm No:- 8454900007 to pay amount. ');</script>");
//textbox clear
TextBox1.Text = "";
TextBox2.Text = "";
TextBox9.Text = "";
TextBox4.Text = "";
DropDownList1.SelectedValue = "Select";
DropDownList3.SelectedValue = "Select";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
DropDownList2.SelectedValue = "Select";
TextBox5.Text = "";
}
protected void chkbox_CheckedChanged(object sender, EventArgs e)
{
if (chkbox.Checked == true)
btnclick0.Enabled = true;
else
btnclick0.Enabled = false;
}
protected void btnpay_Click(object sender, EventArgs e)
{
//Response.Redirect("Payment.aspx");
}
}
--------------
Stylesheet
--------------
body
{
background-image:url('Images/56.jpg');
background-size: cover;
font-size:larger;
background-repeat:no-repeat;
font-family:Baskerville Old Face;
font-weight:bold;
font-size:larger;
}
.con
{
font-size:x-large;
color: white;
text-shadow: 1px 1px 2px black, 0 0 25px black, 0 0 5px black;
border-bottom-color:White;
}
#Button1
{
border-bottom-width:medium;
border-radius:60%;
}
#note
{
color:Red;
}
#form1
{
padding-left:150
}
Comments
Post a Comment