Disable Dates In Jquery Datepicker

Sep 23, 2010

I am using a jquery datepicker and timepicker. In datepicker I want to disable the all dates which are past to the current date. And in timepicker I want to show the times which is one hour prior to the current time.Can anyone tell me how to do this?

View 2 Replies


Similar Messages:

AJAX :: Populate DatePicker With Dates From JQuery

May 7, 2015

protected void Page_Load(object sender, EventArgs e) {
Session["ID"] = "2";
string strConnString = ConfigurationManager.ConnectionStrings["BSDConnectionString"].ConnectionString;
var con = new SqlConnection(strConnString);
using (var sda = new SqlDataAdapter()) {
SqlCommand cmd = new SqlCommand();

[Code] .....

That was my code , now lets see what my problem is :

I am getting only two dates in a single row from sql to my asp.net webform and then bindng those dates in jQuery UI Datepicker. Now if i set session to 1 then date picker works well but if i put session = 2 , it shows the end date till 2020 which is wrong.

Below are the dates which are fetched from database and i have copied here....

When Session["ID"] = "1";

Start Date : 01/07/2014 00:00:00
End Date :   05/02/2015 00:00:00   

When Session["ID"] = "2";

Start Date : 07/04/2015 00:00:00
End Date :   27/08/2016 00:00:00      

I have set my mindate to startdate and maxdate to end date....

Also point of interest is that if i don't fetch values from database and use only List<string> in my web method then every thing works well. Like this :

[WebMethod]
public static List<string> GetDates() {
List<string> arr = new List<string>();
arr.Add("2014-07-01");
arr.Add("2015-02-05");
return arr;
}

View 1 Replies

Display Server Side Dates In Jquery Datepicker?

Feb 18, 2011

i have a textbox1 in my asp.net webform which shows the server side date : i want the user would not select date using jquery datepicker earlier than the date in the textbox1 i m using the following code to show jquery calendar in other textbox2 :

<link href="./themes/sunny/jquery.ui.all.css" rel="stylesheet" type="text/css"/>
<link href="./themes/sunny/jquery.ui.all.css" rel="stylesheet" type="text/css"/>
<script src="./js/jquery.min.js"></script>
<link rel="stylesheet" href="./demos/demos.css">
<script src="./js/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".datepicker").datepicker({
buttonText: 'Select date:',
firstDay: 1,
buttonImage: "./demos/datepicker/images/calendar.gif",
buttonImageOnly: true,
showOn: 'both',
showAnim: 'fadeIn',
minDate: '0',
dateFormat: 'dd-M-yy',
onSelect: function() { $(this).trigger("onchange", null); }
});
});
</script>

View 1 Replies

JQuery DatePicker Not Saving Correct Dates On Partial Postback

Jun 23, 2010

I have some textboxes (in an UpdatePanel in a ModalPopup in a User Control) that look like this:

<asp:TextBox ID="exampleTextBox" runat="server" MaxLength="10"
CssClass="datepicker" ReadOnly=true
Text='<%# Bind("ExampleDateField") %>' Width="77px">
</asp:TextBox>

I also have some jQuery (imported from file on the Master page) that hooks up the jQuery DatePickers like so:

function pageLoad() {
$(".datepicker").unbind();
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
beforeShowDay: $.datepicker.noWeekends,
showOn: 'button',
buttonImage: '../Resources/Images/Calendar_scheduleHS.gif',
buttonImageOnly: true,
buttonText: 'Select a Date'
});
}

The DatePickers appear correctly, even after a postback. The problem is that the value of the textboxes is not changed when a postback occurs. This is very odd since the textbox shows the selected date in the browser. However, the value of the textbox is still the date that the textbox originally had, not the date selected from the datepicker.

View 1 Replies

Dynamically Disable JQuery Datepicker Icon

Feb 24, 2010

I'm fairly new to jQuery and I've been looking for a decent free datepicker for a while now. I am quite satisfied with jQuery UI's datepicker but I've hit a snag. The project where I'm using this requires that I have an icon beside the textbox. While this is fairly easy, I don't know how to dynamically disable the icon. There are two things I'm interested in knowing:

How can I dynamically change the disabled status of the datepicker from code-behind so that it triggers on postback? Is it possible to make it's disabled status dependent on the textbox that it is attached to? (i.e. if

<asp:TextBox Id="txtMyTextBox" Enabled="false">

then datepicker gets disabled as well.

This is the code I've been using for the datepicker.

<script type="text/javascript">
$(function() {
$("*[id$='txtMyTextBox']").datepicker({
changeMonth: true,
changeYear: true,
showOn: 'button',
buttonImage: '/images/icon-calendar.gif',
buttonImageOnly: true
});
});
</script>

View 3 Replies

Disable Dates Using Jquery Inside Gridview Control?

Dec 27, 2010

I have a gridview which contains a textbox control. I need to show the calendar for the user to pick the date and certain dates are to be disabled using jquery. I found a post on stackoverflow that talked about how to disable certain dates. I am done with that part, except not sure how to pass the textbox control to this jquery function. Here is the code.

<script type="text/javascript" language="javascript">
function pageLoad(sender, args) {
var enabledDays = ['09/21/2011', '10/05/2011', '10/19/2011', '11/02/2011', '11/16/2011'];
/* utility functions */
function editDays(date) {
for (var i = 0; i < enabledDays.length; i++) {
if (new Date(enabledDays[i]).toString() == date.toString()) {
return [true];
}
}
return [false];
}
/* create datepicker */
$(document).ready(function() {
$('#<%= txtInHomeDate.ClientID %>').datepicker({
beforeShow: springDate,
beforeShowDay: editDays,
dateFormat: 'mm/dd/yy',
buttonImage: 'images/cal.gif',
buttonText: 'Choose date',
firstDay: 1,
buttonImageOnly: true,
showOn: 'both',
showAnim: 'fadeIn',
onSelect: function() { $(this).trigger("onchange", null); }
});
function springDate() {
var defaultMin = new Date();
var defaultMax = new Date();
var Min = defaultMin;
var Max = defaultMax;
// make valid date from hiddenfied value format is MM/dd/yyyy
dateMin = $('#<%= hfStDate.ClientID %>').val();
dateMin = new Date(dateMin);
dateMax = $('#<%= hfEndDate.ClientID %>').val();
dateMax = new Date(dateMax);
if (dateMin && dateMax) {
Min = new Date(dateMin.getFullYear(), dateMin.getMonth(), dateMin.getDate());
Max = new Date(dateMax.getFullYear(), dateMax.getMonth(), dateMax.getDate());
}
return {
minDate: Min,
maxDate: Max
};
}
});
}
<....
<asp:TemplateField HeaderText="In-Home Date">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:HiddenField ID="hfStDate" runat="server" Value="09/01/2011" />
<asp:HiddenField ID="hfEndDate" runat="server" Value="11/30/2011" />
<asp:TextBox ID="txtInHomeDate" runat="server" />
</ItemTemplate>
</asp:TemplateField>

Currently, it errors out since the jquery function won't find the txtInHomeDate.

View 2 Replies

Jquery Datepicker Not Focused After Date Is Chosen, After Postback Datepicker Doesn't Work

Jan 25, 2011

everytime the user selects a date from my datepicker the for some reason instead of staying focused on the are the date picker is in it scrolls to the top of the page.

Heres the function located at the bottom of my asp.net page under the

<script>
$(function() {
$( "#<%= pissued1.ClientID %>" ).datepicker();
});
</script>

This is the code.

<td align="left" colspan="2">
<strong>
<asp:Label ID="labdi1" runat="server" Text="*Date Issued:"></asp:Label>
<asp:RequiredFieldValidator ID="p1divalidate" runat="server" ControlToValidate="pissued1"
ErrorMessage="You Forgot The">*</asp:RequiredFieldValidator><br />
</strong>
<asp:TextBox ID="pissued1" runat="server" Width="45%"></asp:TextBox>
</td>

and also on postback my datepickers stop working. For example i have a dropdownlist that causes postback and if the user uses the drop downlist then the datepickers stop working

View 1 Replies

JQuery Datepicker Not Working / Want To Add The JQuery Datepicker To The UI

Jun 10, 2010

I'm completely new to JQuery and MVC. I'm working on a pet project that uses both to learn them and I've hit my first snag.

I have a date field and I want to add the JQuery datepicker to the UI. Here is what I have done:

Added <script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
to the site.master

Inside my Create.aspx (View), I have

<asp:Content ID="Create" ContentPlaceHolderID="MainContent" runat="server">
<h2>
Create a Task</h2>
<% Html.RenderPartial("TaskForm"); %>
</asp:Content>

and inside "TaskForm" (a user control) I have:

<label for="dDueDate">
Due Date</label>
<%= Html.TextBox("dDueDate",(Model.Task.TaskID > 0 ? string.Format("{0:g}",Model.Task.DueDate) : DateTime.Today.ToString("MM/dd/yyyy"))) %>
<script type="text/javascript">
$(document).ready(function() {
$("#dDueDate").datepicker();
});
</script>

As you can see, the above checks to see if a task has an id > 0 (we're not creating a new one) if it does, it uses the date on the task, if not it defaults to today. I would expect the datepicker UI element to show up, but instead I get:

"Microsoft JScript runtime error: Object doesn't support this property or method" on the $("#dDueDate").datepicker();

It is probably a very simple mistake, so don't over-analyze. As I said, this is the first time I've dealt with MVC or JQuery so I'm lost as to where to start.

View 3 Replies

JQuery :: Greater And Less Than Date With JQuery And DatePicker In MVC?

Oct 7, 2010

I have this date value fetch from a Controller but when I use jQuery Datepicker with validation, the output is not good.The validation is to check if the value is less than or greater than today's date. JQuery Datepicker works well.If I select a date two days from now using datepicker, the validation error won't occur. [:(]

ViewData("DateToday") = Date.Now.ToShortDateString()
<link href="/css/jQuery/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>

[code]....

View 2 Replies

AJAX :: Disable The Last Day And Last Month Dates?

Sep 15, 2010

i want to disable the last day and last month dates in this control?

View 4 Replies

Web Forms :: How Disable Past Dates On Calendar

May 21, 2010

if looked but couldend find what i was looking for So my Q is:How disable Past dates on Calendar to make it unclickable?

View 2 Replies

Web Forms :: Disable The Dates On The Calendarextender Control?

Jan 8, 2011

How to disable the dates on the Calendarextender control ie: and only highlight the specific dates ( the date is coming from DB dynamically )

so if i have the dates like 5 , 8 , 24 , 28 Jan 2011 - i have to highlight these dates with background somecolor and change some text color, and disable other dates.

Is it possible to do this using CalendarExtender control I google but i didnt get any way of doing the above task, If not so which calendar control wil fulfil my requirement. and also i have to show the calendar similar to the calendarextender.

View 7 Replies

Disable A Collections Of Dates For Telerik DateTimePicker?

Jan 5, 2011

For telerik DateTimePicker, I need you to disable a collection of certain dates, so user cannot select them? Is there any client/server side events that can do this?

View 1 Replies

AJAX :: Disable Past Dates In Calendarextender?

Apr 10, 2010

i want to know how to disable past dates in ajax calendar extender so user can not select past dates.

View 1 Replies

AJAX :: CalendarExtender - Disable Specific Dates

Dec 15, 2013

This question is regarding one of your article on disabling future dates in [URL] ....

Your code in the above link disables(prevents for selection) dates for selection greater than today.

But I want to prevent users from selecting dates after a particular date say for example-after 13th October 2013, all the dates should be disabled.

I replaced this line

 var c = (new Date).setHours(0, 0, 0, 0);
with
var c = (new Date("October 13, 2013 11:00:00")).setHours(0,0,0,0);

in the javascript file(Extension.min.js).

But still it was disabling dates other than today.

View 1 Replies

JQuery :: How To Use Jquery Datepicker As Usercontrol

Nov 18, 2010

I am new for Jquerry,I have a user control with a Jquerry calender control,but i am geting "Microsoft JScript runtime error: Object expected" this error when i m trying to add in .aspx page.

can anybody suggest the solution:

.ascx Page:

<script type="text/javascript" src="~/js/jquery-1.3.1.min.js"></script>
<script src="~/js/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>
<script src="~/js/daterangepicker.jQuery.js" type="text/javascript"></script>
<link href="~/css/ui.daterangepicker.css" rel="stylesheet" type="text/css" />
<link href="~/css/redmond/jquery-ui-1.7.1.custom.css" rel="stylesheet" type="text/css" />
<script type=text/javascript>
Calender()
{
$(function() {
$("#<%= TextBox1.ClientID %>").attr("readonly", "readonly");
$("#<%= TextBox1.ClientID %>").attr("unselectable", "on");
// $("#<%= TextBox1.ClientID %>").daterangepicker({ presetRanges: [], arrows: true, dateFormat: 'd M, yy', clearValue: '', datepickerOptions: { changeMonth: true, changeYear: true} });
$("#<%= TextBox1.ClientID %>").daterangepicker({arrows: true, dateFormat: 'd M, yy', clearValue: '', datepickerOptions: { changeMonth: true, changeYear: true} });
}
);
}
</script>
<asp:TextBox ID="txtDateOfBirth" runat="server"
Width="82%" BorderColor="#f4785e" TabIndex="-1"></asp:TextBox>
------------------------------------------------------
UI.aspx:
<uc3:AgeCalUsercontrol ID="AgeCalUsercontrol1" runat="server" />

View 5 Replies

JQuery :: Is It Possible To Use Asp:Textbox For JQuery Datepicker

Oct 27, 2010

is it possible to use asp:Textbox for JQuery Datepicker?

View 2 Replies

JQuery :: How To Add Datepicker In Code Behind

Dec 10, 2010

how to add Datepicker in code behind

[Code]....

View 16 Replies

Use JQuery DatePicker On Textbox?

Nov 25, 2010

I am new to JQuery and want to know how to attach DatePicker to textbox.

View 3 Replies

JQuery :: Get DatePicker Plug In?

Oct 10, 2010

Is there an easy way to get the datePicker plugin? Currently, I include the following jquery in a web page: [Code]....

At the jquery site, the download for datePicker has a bunch of files. And I am confused by the instructions. Went to another site for datePicker, and I get "object not supported" errors.Is there a simple "jquery-latest-UI.js" file I can include in the web page?

View 3 Replies

JQuery :: Use DatePicker Within DataGrid?

Mar 30, 2011

I am using VS2005

I have got a Datagrid which has got a textbox in a cell in each row. How can I use the jQuery datepicker with the textbox?

View 6 Replies

JQuery :: Datepicker Has No Style?

Aug 18, 2010

My date picker has no style as in it doesnt seem to be recognising the style sheet

[Code]....

and my html

[Code]....

View 2 Replies

Forms Data Controls :: Calendar DayRender : Disable Dates?

Jan 16, 2011

i am trying to solve this problem but cann't think of a perfect solution.suppose i have a list of days

String[] dayInWeek = { "3", "5", "7" } these out of the 7 days in a week

now i want to disable all the weekdays in the calander (disable these days in each week).how can i do that?

View 5 Replies

AJAX :: Disable Dates In One Calendar Based On Date Selected

May 7, 2015

I want to block Year From Calender .I have 2 text box in first text box i select Start Financial Year And in second Text End Financial Year.When i Select 2009 year in first text box then in second texbox all dates privious from 2009 will be block.

View 1 Replies

JQuery :: Popout Datepicker From Textbox

Oct 21, 2010

i have a simple asp.net textbox. can someone provide me with an example so that when the user clicks inside the textbox, a jquery datepicker popsout? also, i need it so that when the user clicks a date in the datepicker, the textbox is populated with this date.

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved