My problem is the following :
On my website, I use the Jquery-ui datepicker to allow my visitor to enter a date.
I have configured the datepicker such users can modify the month and the year.
However, I have noticed that they never enter the year : they leave in the default value.
In my mind, they don't see that they can edit the year value...
So, I would like to intialize the default year value to empty/blank and show an error alert if the user has not modified it.
I try to do that, but in vain....
So how can I do that ?
Maybe, there is an other way to force my users to select a correct year value. Have you got any suggestions ?
In advance, thanks for your answer.
I thought a little bit and I think what I would do is not possible...
How could the datpicker calculate the days of the month if the year is not specified?
So, Have you got any suggestions to force my users to change the year default value ?
You could identify what the default value is and then, in your onSelect callback you could see if the current year value is different than what the original was and execute whatever code seems appropriate.
Related
I'm trying to update the calendar firstWeekDay to something else (as far as I seen the default firstWeekDay is Sunday) but some errors occur.
private var calendar = Calendar.autoupdatingCurrent
calendar.firstWeekday = 3
// the 2nd line is here only to ask this question on StackOverFlow (is missing on my code because I am want the user to use its own calendar, not something forced by me.
Check code+errors screenshot here
Note: I managed to do this at the beginning of the project with the same simple code but after a while I updated the app on my personal iPhone to check how it looks and behave on a real device and I noticed that the the first week day is not Monday anymore as my personal iPhone calendar is set.
I managed to solve the issue. Apparently I had to define a new function and update the firstWeekDay property inside that function. :)
Has anyone had any luck in figuring out how to use the react library https://react-day-picker.js.org/docs/input/
With Capybara/Selenium? Unfortunately it doesn't allow simply typing in the text such as MM/DD/YYYY like most date-pickers. This only allows mouse selection.
Or is specifically setting the value basically the only way to do so?
Without an example which shows the actual configuration of react-day-picker you're dealing with it's impossible to say exactly what you need to do, but the general rule is if you are testing the sites functionality then do what a user would need to do. In your case that may mean click on the forward/back month arrows until you get to the desired month, then click on the specific day element. Assuming the date you want to select is in the future (September 20, 2019) it would be something like
caption = find('.DayPicker-Caption')
until caption.has_text?('September 2019', wait: 0) do
current_month = caption.text
find('.DayPicker-NavButton--next').click
# wait for month to change
expect(caption).not_to have_text(current_month)
end
find('.DayPicker-Day', exact_text: '20').click
If you're not actually testing functionality (web scraping, etc) then you can use execute_script to call the react-day-picker JS API and set a specific date.
I'm pretty sure the answer must be no, since if I set its minimumDate to an earlier date, it still stops rolling back at 1 AD. Also if I set its start date to a BC/BCE date it goes to 1/1/1. I'm just hoping there is some secret trick someone might know.
Only by using a custom UIPickerView to do what you want I'm afraid...
I have checked a lot of related questions, but no one actually solve my problem.
I am now writing a rails app and use fullCalendar.
I am able to show events on my calendar, but with start time and the title of the event.
Actually these is end time for the even under the month view, and events longer than 30 mins under the week and day view. But no end time for the events of duration less than 30 minutes under view of week and day.
Besides, I hope not to show the title of the event. I find other answers says it will need to change the source file of fullcanlendar, I am wondering if there is any way to do it without changing the souce code of full calendar.
You may be looking for the eventRender callback:
http://fullcalendar.io/docs/event_rendering/eventRender/
With this, you can alter the event's html element however you need to.
imagine that you have an index.gsp with two dates: Starting day and Ending Day.
When the user picks the starting day, how can I calculate + 2 months in the ending day?
I know in the controller I could have something like:
use (TimeCategory) {
c = new Date() + 2.month
}
But how is the best way to change the Ending Day in the gsp? With remoteFunction?
EDIT:
Yes it worked, thank you very much lukelazarovic.
Like you said the only thing needed to change was the last line, I changed to: $("#myid_month").val(month+3);
function dateWasChanged(){
....
$("#myid_month").val(month+3);
}
EDIT2:
I also needed to increment year, for some reason they are strings so remember to do:
myInteger = parseInt(myString);
I assume you want to do it on the client - without reloading page +2 months date is set into the end date datePicker.
That means you have to do it using Javascript or Javascript-based framework (JQuery).
You can go along with the solution suggested in this SO question: Get Date value from Grails DatePicker
Only change would be to set the value of end datePicker on the last line of function dateWasChanged like this:
$("#endDatePickerId").datpicker("setDate", date);