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 />
<asp:Label ID="Label1" runat="server" Text="Vardas:"></asp:Label>
<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 />
<asp:Label ID="Label6" runat="server" Text="Pavardė:"></asp:Label>
<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 />
<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" />
<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 />
<asp:Label ID="Label8" runat="server" Text="Dalyvių kiekis: 0"></asp:Label>

View File

@ -47,14 +47,21 @@ namespace ValidWeb
protected void Button1_Click(object sender, EventArgs e)
{
string name = TextBox1.Text;
if (Regex.IsMatch(name, @"[^a-zA-ZąčęėįšųūžĄČĘĖĮŠŲŪŽ]")) { return; }
string surname = TextBox2.Text;
if (Regex.IsMatch(surname, @"[^a-zA-ZąčęėįšųūžĄČĘĖĮŠŲŪŽ]")) { return; }
string school = TextBox3.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);
if (Session["users"] == null) {

View File

@ -7,12 +7,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace ValidWeb
{
namespace ValidWeb {
public partial class Forma1
{
public partial class Forma1 {
/// <summary>
/// form1 control.
@ -60,13 +58,13 @@ namespace ValidWeb
protected global::System.Web.UI.WebControls.TextBox TextBox1;
/// <summary>
/// RequiredFieldValidator1 control.
/// RegularExpressionValidator1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
/// <summary>
/// Label6 control.
@ -87,13 +85,13 @@ namespace ValidWeb
protected global::System.Web.UI.WebControls.TextBox TextBox2;
/// <summary>
/// RequiredFieldValidator2 control.
/// RegularExpressionValidator2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
/// <summary>
/// Label7 control.