Custom-Validator eingefügt.
This commit is contained in:
@@ -105,12 +105,14 @@
|
||||
<div class="col-12" id="container2" style="margin-left:2px;">
|
||||
<asp:Label ID="lbl_von" runat="server" Text="Von:"></asp:Label>
|
||||
<asp:TextBox id="pickdate1" Type="Date" CssClass="classTarget" requiered="true" runat="server"></asp:TextBox>
|
||||
<!--<asp:RequiredFieldValidator ID="RequiredFieldValidatorvon" runat="server" ErrorMessage="Field required" ControlToValidate="pickdate1" Text="Required" ForeColor="White" Font-Strikeout="False" Font-Underline="False" Font-Overline="False" Font-Bold="True" BackColor="Red"></asp:RequiredFieldValidator>
|
||||
<asp:CustomValidator runat="server" ID="valDateRange_1" ControlToValidate="pickdate1" onservervalidate="valDateRange_1_ServerValidate" ErrorMessage="enter valid date" />
|
||||
<!--<asp:RequiredFieldValidator ID="RequiredFieldValidatorvon" runat="server" ErrorMessage="Field required" ControlToValidate="pickdate1" Text="Required" ForeColor="White" Font-Strikeout="False" Font-Underline="False" Font-Overline="False" Font-Bold="True" BackColor="Red"></asp:RequiredFieldValidator>
|
||||
<asp:CustomValidator ValidateEmptyText="false" ClientValidationFunction="instantValidation"></asp:CustomValidator> -->
|
||||
<asp:Label ID="lbl_bis" runat="server" Text="Bis:"></asp:Label>
|
||||
<!-- <asp:RequiredFieldValidator ID="RequiredFieldValidatorbis" ClientValidationFunction="validate" runat="server" ErrorMessage="Field required" ControlToValidate="pickdate2" Text="Required" ForeColor="White" Font-Strikeout="False" Font-Underline="False" Font-Overline="False" Font-Bold="True" BackColor="Red"></asp:RequiredFieldValidator> -->
|
||||
<asp:TextBox id="pickdate2" Type="Date" CssClass="classTarget" required="true" runat="server"></asp:TextBox>
|
||||
</div>
|
||||
<asp:CustomValidator runat="server" ID="valDateRange_2" ControlToValidate="pickdate2" onservervalidate="valDateRange_2_ServerValidate" ErrorMessage="enter valid date" />
|
||||
</div>
|
||||
<div id="Abstand"></div>
|
||||
<hr>
|
||||
|
||||
|
||||
@@ -16,41 +16,60 @@ Partial Class Kundenbereich_Default
|
||||
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
||||
Page.UnobtrusiveValidationMode = UnobtrusiveValidationMode.WebForms
|
||||
DataBind()
|
||||
tbl_Header_row.TableSection = TableRowSection.TableHeader
|
||||
tbl_Header_row.TableSection = TableRowSection.TableHeader
|
||||
' MsgBox(datebis)
|
||||
If (Page.IsPostBack And normaltable.EnableViewState = False) Then
|
||||
normaltable.EnableViewState = True
|
||||
If rbt_Alle.Checked = True Then
|
||||
lbl_von.Visible = True
|
||||
lbl_bis.Visible = True
|
||||
pickdate1.Visible = True
|
||||
pickdate2.Visible = True
|
||||
ElseIf rbt_Alle_M.Checked = True Then
|
||||
lbl_von.Visible = True
|
||||
lbl_bis.Visible = True
|
||||
valDateRange_1.Enabled = True
|
||||
valDateRange_2.Enabled = True
|
||||
pickdate1.Visible = True
|
||||
pickdate2.Visible = True
|
||||
ElseIf rbt_Freig.Checked = True Then
|
||||
lbl_von.Visible = True
|
||||
lbl_bis.Visible = True
|
||||
pickdate1.Visible = True
|
||||
pickdate2.Visible = True
|
||||
ElseIf rbt_Freig_M.Checked = True Then
|
||||
lbl_von.Visible = True
|
||||
lbl_bis.Visible = True
|
||||
valDateRange_1.Enabled = True
|
||||
valDateRange_2.Enabled = True
|
||||
pickdate1.Visible = True
|
||||
pickdate2.Visible = True
|
||||
Else
|
||||
lbl_von.Visible = False
|
||||
lbl_bis.Visible = False
|
||||
valDateRange_1.Enabled = False
|
||||
valDateRange_2.Enabled = False
|
||||
pickdate1.Visible = False
|
||||
pickdate2.Visible = False
|
||||
End If
|
||||
|
||||
If rbt_Alle_M.Checked = True Then
|
||||
lbl_von.Visible = True
|
||||
lbl_bis.Visible = True
|
||||
valDateRange_1.Enabled = True
|
||||
valDateRange_2.Enabled = True
|
||||
pickdate1.Visible = True
|
||||
pickdate2.Visible = True
|
||||
ElseIf rbt_Freig_M.Checked = True Then
|
||||
lbl_von.Visible = True
|
||||
lbl_bis.Visible = True
|
||||
valDateRange_1.Enabled = True
|
||||
valDateRange_2.Enabled = True
|
||||
pickdate1.Visible = True
|
||||
pickdate2.Visible = True
|
||||
Else
|
||||
lbl_von.Visible = False
|
||||
lbl_bis.Visible = False
|
||||
valDateRange_1.Enabled = False
|
||||
valDateRange_2.Enabled = False
|
||||
pickdate1.Visible = False
|
||||
pickdate2.Visible = False
|
||||
End If
|
||||
|
||||
datevon = Date.Parse(pickdate1.Text)
|
||||
datebis = Date.Parse(pickdate2.Text)
|
||||
Else
|
||||
normaltable.EnableViewState = True
|
||||
Else
|
||||
normaltable.EnableViewState = True
|
||||
Dim erster = New Date(Now().Year, Now().Month, 1)
|
||||
Dim ersterdat = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
|
||||
pickdate1.Text = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
|
||||
@@ -459,5 +478,22 @@ Partial Class Kundenbereich_Default
|
||||
pickdate2.BorderStyle = BorderStyle.None
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub valDateRange_1_ServerValidate(source As Object, args As ServerValidateEventArgs)
|
||||
Dim minDate As DateTime = DateTime.Parse("01.04.2001")
|
||||
Dim maxDate As DateTime = DateTime.Parse(DateTime.Now.ToShortDateString)
|
||||
Dim dt As DateTime
|
||||
|
||||
args.IsValid = (DateTime.TryParse(args.Value, dt) AndAlso
|
||||
dt <= maxDate AndAlso
|
||||
dt >= minDate)
|
||||
End Sub
|
||||
Protected Sub valDateRange_2_ServerValidate(source As Object, args As ServerValidateEventArgs)
|
||||
Dim minDate As DateTime = DateTime.Parse("01." + Date.Now.Month.ToString + ".2001")
|
||||
Dim maxDate As DateTime = DateTime.Parse(DateTime.Now.ToShortDateString)
|
||||
Dim dt As DateTime
|
||||
|
||||
args.IsValid = (DateTime.TryParse(args.Value, dt) AndAlso
|
||||
dt <= maxDate AndAlso
|
||||
dt >= minDate) And dt < Date.Now.AddDays(-1)
|
||||
End Sub
|
||||
End Class
|
||||
@@ -152,8 +152,14 @@ hr{
|
||||
background-color:salmon;
|
||||
border: 1px solid red;
|
||||
}
|
||||
@media (max-width: 558.98px) {
|
||||
h1 {
|
||||
#pickdate1:valid{
|
||||
color:black;
|
||||
}
|
||||
#pickdate1:invalid{
|
||||
border: 1px solid red;
|
||||
}
|
||||
@media (max-width: 558.98px) {
|
||||
h1 {
|
||||
color: #043381;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user