Hi nauna,
Check this example. Now please take its reference and correct your code.
HTML
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker3.min.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css" />
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('[id*=txttime]').timepicker({
defaultTime: '12:00 AM'
});
$('[id*=txtdate]').datepicker({
startDate: new Date(),
multidate: false,
format: "mm/dd/yyyy",
daysOfWeekHighlighted: "5,6",
//datesDisabled: ['31/08/2017'],
language: 'en'
}).on('changeDate', function (e) {
// `e` here contains the extra attributes
$(this).find('.input-group-addon .count').text(' ' + e.dates.length);
});
});
</script>
<div class="form-group col-md-3">
Date
<asp:TextBox ID="txtdate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Field Required"
CssClass="required" ControlToValidate="txtdate" Display="Dynamic" ValidationGroup="form"></asp:RequiredFieldValidator>
</div>
<div class="form-group col-md-3">
Time
<asp:TextBox ID="txttime" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="Field Required"
CssClass="required" ControlToValidate="txttime" Display="Dynamic" ValidationGroup="form"></asp:RequiredFieldValidator>
</div>
<asp:Button Text="Save" OnClick="Save" runat="server" />
Code
C#
protected void Save(object sender, EventArgs e)
{
string[] weekDays = new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
if (weekDays.Contains(Convert.ToDateTime(txtdate.Text.Trim()).DayOfWeek.ToString()))
{
if (Convert.ToDateTime(txttime.Text.Trim()) >= Convert.ToDateTime("8am") && Convert.ToDateTime(txttime.Text.Trim()) <= Convert.ToDateTime("5pm"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('cost is $26')", true);
}
}
}
VB.Net
Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs)
Dim weekDays As String() = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}
If weekDays.Contains(Convert.ToDateTime(txtdate.Text.Trim()).DayOfWeek.ToString()) Then
If Convert.ToDateTime(txttime.Text.Trim()) >= Convert.ToDateTime("8am") AndAlso Convert.ToDateTime(txttime.Text.Trim()) <= Convert.ToDateTime("5pm") Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "alert('cost is $26')", True)
End If
End If
End Sub
Screenshot