clearing dates from bootstrap datepicker - twitter-bootstrap-3

I am using bootstrap datepicker. I need to show selected dates from the datepicker to the div at right hand side along with a trash symbol. when i click on trash symbol , the selected date need to be cleared from bootstrap datepicker also. But i do not know how to do it? Do you have any ideas?
I tried:
$('.datepickerBootstrap').datepicker("clearDates");
But it clears all dates.
Also tried with
$('.datepickerBootstrap').datepicker('update', '');
check out my fiddle here: http://jsfiddle.net/f2p8v3co/1/

This should work if you want to clear out the date. Update your fiddle with this code
$('.datepickerBootstrap').datepicker('update', '');
But if you want to update the date then you should use
$('.datepickerBootstrap').datepicker('setDates', '');
Hope it helps

Related

How select date in calendar with Selenium?

Here is the html for calendar. How to select date using css selector, xpath or something else.
http://wklej.org/id/2772453/ - FIRST CLICK ON CALENDAR
http://wklej.org/id/2772455/ - SECOND CLICK ON CALENDAR
ClickElementById("ctl00_ctl00_ctl00_ContentPlaceHolderCenter_ContentPlaceHolderBody_ContentPlaceHolderBody_dfSalesAgrementData_imgSetDate");
ClickElementByCssSelector("td:contains('Dzisiaj')");
This works. But if i try to click on calendar again and select date this does not work. Only first time date selection works. I cant change date.
I have this. But that works only once too.
ClickElementById("ctl00_MainContentPlaceHolder_dFieldContractEndDate_imgSetDate");
ClickElementByXPath("html/body/div[1]/table/tbody/tr[4]/td[4]");
Your question is a bit hard to understand and based on my understanding, can you please try this?
ClickElementByCssSelector("td[class='day selected today']");

Trying to fill textbox value with today's date only on visual basics

I am trying to fill a textbox value with the current date and I do not want the user to be able to change the date. I want to use a textbox and not a datepicker. I would like the form to load with today's date already loaded in the textbox, which I will then use in my insert query.
I want the date format of yyyy-MM-dd to be in the textbox memberregisterationdate.text. I am not sure where on my form I should put the code either.
Really stuck on this and I can't seem to find it anywhere
Thanks in advance
You have to make it Enabled = False to disable it. You can load it in Form_Load:
memberregisterationdate.Text = Date.Today.ToString("yyyy-MM-dd")

How to select date from datepicker in selenium

I want to select date from datepicker, below things i tried
Identify the text box in which selected date gets entered.
Identify the datepicker ICON and click on that so that it gets open with current
date highlighted.
Here if I pass required date directly to date text box through sendkeys, it works. But i want to select the date from datepicker which is very old like "10/2/1895", then how to do..?
Html Code:
<img src="/img/default/extjs/s.gif?hash=797058701" class="x-form-trigger x-form-date-trigger " id="ext-gen7">
Clicking on the image which opens dataPickerCalendar
Driver.pFCreateTaskUnderProject.getDpImage().click();
Driver.pFCreateTaskUnderProject.getTxtDateOFBirth()...????????
Here i am not able to proceed. How to select the date[10-2-1952] from the calendar..?
If manual then we will go back to 1952, then select 2nd month and 10th Date. But with automation how to do this...?
Thanks
Mahesh

Custom coloring a gridcell in dijit.calendar and keeping it persistent

I am using dojo 1.6 and using dijit.calendar in a project and it's working great except for the goal of colorizing a selected grid cell. I have three innerHTMLs that are being manipulated by the calendar clicks. No problem there.
dijit.calendar's behavior is to highlight a gridcell (calendar day) as blue when clicked and when another gridcell is clicked, it then turns that blue.
What I'd like to do is colorize the cell a custom color when it's clicked and have it persistent.
Specifically the calendar is for a project that has an official date (blue), start date (green) and an end date (red).
I'm not even aware that there is a way to colorize a specific gridcell in dijit.calendar. Has anyone successfully done this or have a pointer to send me in the right direction?
Edit below:..
OK folks, I have a pretty good lead on where to go with this thanks to Philippe below. Philippe's solution will color the cell EXACTLY as intended (so he's got the answer karma). Turns out that if a selected grid cell is red and I switch to the month to pick a subsequent date, the cell stays red.
I have most of it figured out. I can get, say, the first couple of dates successfully colored but if I have to do something like put in a third date in the next month and change the calendar, the cells stay colored. So there's going to have to be a way to change my color change to a distinct value that corresponds with the actual date.
I know that onChange that the only argument returned is the Date itself like this (using debug.console in Firebug).....
[Date {Wed Jan 18 2012 00:00:00 GMT-0500 (EST)}]
I inspected the code through Firebug and noticed in that same cell that the code looks like this....
<td role="gridcell" class="dijitCalendarSelectedDate dijitCalendarCurrentMonth dijitCalendarDateTemplate" dijitdatevalue="1326866400000" style="background-color: green;" tabindex="0"><span class="dijitCalendarDateLabel">18</span></td>
That distinct value seems to be "dijitdatevalue".
I suppose I could follow a chain of ......
on click, store the "dijitdatevalue" of the first date in a hidden field (as well as the second and third dates)
Then go back and set the background-color of the corresponding dijitdatevalue to blue, green or red.
Question now is how to return the dijitdatevalue string to a hidden field. I'll update this post again as I figure out the answer.
Janie
If you look at the widget code you'll see a private method called _onDayMouseDown which is responsible for turning the cell blue...
You can add your custom code to that function through dojo.connect, like this :
dojo.connect(dijit.byId('calendar1'), "_onDayMouseDown", function(/*Event*/ evt){
var node = evt.target.parentNode;
dojo.style(node, "backgroundColor", "green");
});
Otherwise, if you use dojo 1.7, you may give a try to the MultiSelectCalendar

Make VB.Net DatePicker Required

I have a datepicker in a vb.net clickonce application. I need to make sure that in order to use the application that selecting a valid date is required. Ideally, I would be able to set the value of the datepicker to null and then programatically create Try Catch logic based on datepicker1.value still being null. Unfortunately, it will not allow me to assign a null or blank value to the datepicker. I cannot create my logic based on any real values of the datepicker because who's to say the value picked is not valid. I've tried setting the value to some outrageous date that no one would pick for the application like 1/1/1970, but then the datepicker opens up at 1/1/1970 and drops that date in as soon as it gains focus. I need a way to validate whether or not someone has selected a date, but am stuck and can't find any real help online. I am not looking to set the customformat = "", so please do not respond with that solution. I need the actual value to be blank or something I can run validation against to know that the user has in fact selected a date.
Set the ShowCheckBox property to true. That will make the control look like this...
When the user selects a date, it will check the checkbox. Then when you need the value...
If datePicker.Checked Then
'user has selected a value
Else
'user has NOT selected a value
End If
Can you use the ValueChanged event to set a flag to tell you they've clicked on a date?
UPDATE
You could also use the OnClick method to set a flag to verify the user actually clicked on the DateTimePicker.