1
0

feat: finish "Practice.ValidWeb"

This commit is contained in:
Rokas Puzonas 2022-02-21 15:26:26 +02:00
parent 125803db82
commit 5ede3c929c
3 changed files with 43 additions and 38 deletions

View File

@ -14,12 +14,12 @@
<br /> <br />
<asp:Label ID="Label1" runat="server" Text="Vardas:"></asp:Label> <asp:Label ID="Label1" runat="server" Text="Vardas:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Vardas yra privalomas" ForeColor="Red"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Netinkamas vardas" ForeColor="Red" ValidationExpression="^[a-zA-ZąčęėįšųūžĄČĘĖĮŠŲŪŽ]+"></asp:RegularExpressionValidator>
<br /> <br />
<br /> <br />
<asp:Label ID="Label6" runat="server" Text="Pavardė:"></asp:Label> <asp:Label ID="Label6" runat="server" Text="Pavardė:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="Pavardė yra privaloma" ForeColor="Red"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="Netinkama pavardė" ForeColor="Red" ValidationExpression="^[a-zA-ZąčęėįšųūžĄČĘĖĮŠŲŪŽ]+"></asp:RegularExpressionValidator>
<br /> <br />
<br /> <br />
<asp:Label ID="Label7" runat="server" Text="Mokykla:"></asp:Label> <asp:Label ID="Label7" runat="server" Text="Mokykla:"></asp:Label>
@ -42,7 +42,7 @@
<asp:Button ID="Button1" runat="server" Text="Registruotis" OnClick="Button1_Click" /> <asp:Button ID="Button1" runat="server" Text="Registruotis" OnClick="Button1_Click" />
<br /> <br />
<br /> <br />
<asp:Button ID="Button2" runat="server" Text="Išvalyti" OnClick="Button2_Click" /> <asp:Button ID="Button2" runat="server" Text="Išvalyti" OnClick="Button2_Click" CausesValidation="False" />
<br /> <br />
<br /> <br />
<asp:Label ID="Label8" runat="server" Text="Dalyvių kiekis: 0"></asp:Label> <asp:Label ID="Label8" runat="server" Text="Dalyvių kiekis: 0"></asp:Label>

View File

@ -47,15 +47,22 @@ namespace ValidWeb
protected void Button1_Click(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e)
{ {
string name = TextBox1.Text; string name = TextBox1.Text;
if (Regex.IsMatch(name, @"[^a-zA-ZąčęėįšųūžĄČĘĖĮŠŲŪŽ]")) { return; }
string surname = TextBox2.Text; string surname = TextBox2.Text;
if (Regex.IsMatch(surname, @"[^a-zA-ZąčęėįšųūžĄČĘĖĮŠŲŪŽ]")) { return; }
string school = TextBox3.Text; string school = TextBox3.Text;
string age = DropDownList1.Text; string age = DropDownList1.Text;
string language = CheckBoxList1.SelectedValue; string language = "";
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
language += item.Text + " ";
}
}
language = language.TrimEnd();
string user = String.Join("|", name, surname, school, age, language); string user = String.Join("|", name, surname, school, age, language);
if (Session["users"] == null) { if (Session["users"] == null) {
Session["users"] = user; Session["users"] = user;

View File

@ -7,13 +7,11 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace ValidWeb namespace ValidWeb {
{
public partial class Forma1 {
public partial class Forma1
{
/// <summary> /// <summary>
/// form1 control. /// form1 control.
/// </summary> /// </summary>
@ -22,7 +20,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1; protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary> /// <summary>
/// Label5 control. /// Label5 control.
/// </summary> /// </summary>
@ -31,7 +29,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Label Label5; protected global::System.Web.UI.WebControls.Label Label5;
/// <summary> /// <summary>
/// ValidationSummary1 control. /// ValidationSummary1 control.
/// </summary> /// </summary>
@ -40,7 +38,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.ValidationSummary ValidationSummary1; protected global::System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
/// <summary> /// <summary>
/// Label1 control. /// Label1 control.
/// </summary> /// </summary>
@ -49,7 +47,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Label Label1; protected global::System.Web.UI.WebControls.Label Label1;
/// <summary> /// <summary>
/// TextBox1 control. /// TextBox1 control.
/// </summary> /// </summary>
@ -58,16 +56,16 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.TextBox TextBox1; protected global::System.Web.UI.WebControls.TextBox TextBox1;
/// <summary> /// <summary>
/// RequiredFieldValidator1 control. /// RegularExpressionValidator1 control.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Auto-generated field. /// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1; protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
/// <summary> /// <summary>
/// Label6 control. /// Label6 control.
/// </summary> /// </summary>
@ -76,7 +74,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Label Label6; protected global::System.Web.UI.WebControls.Label Label6;
/// <summary> /// <summary>
/// TextBox2 control. /// TextBox2 control.
/// </summary> /// </summary>
@ -85,16 +83,16 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.TextBox TextBox2; protected global::System.Web.UI.WebControls.TextBox TextBox2;
/// <summary> /// <summary>
/// RequiredFieldValidator2 control. /// RegularExpressionValidator2 control.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Auto-generated field. /// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2; protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
/// <summary> /// <summary>
/// Label7 control. /// Label7 control.
/// </summary> /// </summary>
@ -103,7 +101,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Label Label7; protected global::System.Web.UI.WebControls.Label Label7;
/// <summary> /// <summary>
/// TextBox3 control. /// TextBox3 control.
/// </summary> /// </summary>
@ -112,7 +110,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.TextBox TextBox3; protected global::System.Web.UI.WebControls.TextBox TextBox3;
/// <summary> /// <summary>
/// RequiredFieldValidator3 control. /// RequiredFieldValidator3 control.
/// </summary> /// </summary>
@ -121,7 +119,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3; protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
/// <summary> /// <summary>
/// Label2 control. /// Label2 control.
/// </summary> /// </summary>
@ -130,7 +128,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Label Label2; protected global::System.Web.UI.WebControls.Label Label2;
/// <summary> /// <summary>
/// DropDownList1 control. /// DropDownList1 control.
/// </summary> /// </summary>
@ -139,7 +137,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.DropDownList DropDownList1; protected global::System.Web.UI.WebControls.DropDownList DropDownList1;
/// <summary> /// <summary>
/// RangeValidator1 control. /// RangeValidator1 control.
/// </summary> /// </summary>
@ -148,7 +146,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.RangeValidator RangeValidator1; protected global::System.Web.UI.WebControls.RangeValidator RangeValidator1;
/// <summary> /// <summary>
/// Label3 control. /// Label3 control.
/// </summary> /// </summary>
@ -157,7 +155,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Label Label3; protected global::System.Web.UI.WebControls.Label Label3;
/// <summary> /// <summary>
/// CheckBoxList1 control. /// CheckBoxList1 control.
/// </summary> /// </summary>
@ -166,7 +164,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.CheckBoxList CheckBoxList1; protected global::System.Web.UI.WebControls.CheckBoxList CheckBoxList1;
/// <summary> /// <summary>
/// Kalbos control. /// Kalbos control.
/// </summary> /// </summary>
@ -175,7 +173,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.XmlDataSource Kalbos; protected global::System.Web.UI.WebControls.XmlDataSource Kalbos;
/// <summary> /// <summary>
/// Button1 control. /// Button1 control.
/// </summary> /// </summary>
@ -184,7 +182,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Button Button1; protected global::System.Web.UI.WebControls.Button Button1;
/// <summary> /// <summary>
/// Button2 control. /// Button2 control.
/// </summary> /// </summary>
@ -193,7 +191,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Button Button2; protected global::System.Web.UI.WebControls.Button Button2;
/// <summary> /// <summary>
/// Label8 control. /// Label8 control.
/// </summary> /// </summary>
@ -202,7 +200,7 @@ namespace ValidWeb
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Label Label8; protected global::System.Web.UI.WebControls.Label Label8;
/// <summary> /// <summary>
/// Table1 control. /// Table1 control.
/// </summary> /// </summary>