Hi Luo
As promised, here is a comprehensive list of all the points where date fields are being displayed on forms and the behaviour (correct or incorrect). In order to test all these 8 cases properly, I suggest you create new users for yourself:
Please create yourself a new fake family user (<site-url>/en/sign-up/) and nanny user (<site-url>/en/become-a-native-nanny/). Once created, the first time you log in with them you will be using the "Post Form - New Family User" (1) and "Post Form - New Native Nanny User" (2) forms. Once the Nanny and Family posts are created, logging in again with the same credentials will be using the "Post Form - Edit Unverified Family User" (3) and "Post Form - Edit Unverified Nanny User" (4) forms.
1) Post Form - New Family User
<site_url>/en/sign-up/
Datepicker limiting values correctly to dates earlier than 18 years ago
2) Post Form - New Native Nanny User
<site_url>/en/become-a-native-nanny/
Datepicker limiting values correctly to dates earlier than 18 years ago
Code being used in 1) and 2):
jQuery(document).on('cred_form_ready', function(){
jQuery( ".js-wpt-date" ).datepicker("option", "minDate", "-100Y").datepicker("option", "maxDate", "-18Y");;
});
3) Post Form - Edit Unverified Family User
<site_url>/en/sign-up-complete-profile/
Field blank instead of showing the stored date on loading the edit form
Datepicker limits values correctly to 18 years ago
4) Post Form - Edit Unverified Nanny User
<site_url>/en/become-a-native-nanny-complete-profile/
Field value shown correctly on loading the edit form
Datepicker highlights correct date value from the database on loading the datepicker
Datepicker limits values correctly to 18 years ago
Forms 3) and 4) are using the same JavaScript code provided, so it is curious that it works in one edit form but not the other:
jQuery(document).on('cred_form_ready', function(){
jQuery('.js-wpt-date').each(function() {
val = jQuery(this).val();
jQuery(this).datepicker("option", "minDate", "-100Y").datepicker("option", "maxDate", "-18Y").datepicker("option", "dateFormat", 'dd/mm/yy');
jQuery(this).datepicker("setDate", new Date(val));
});
});
To continue reproducing the test cases, you will need to change the role of your new fake Family and fake Nanny from "Unverified Family" to "Family" and "Unverified Nanny" to "Native Nanny" in the back end.
As role Family, you can now click the Ad icon in the menu and "Place a Job Ad".
5) Post Form - New Job Ad
<site_url>/en/place-a-job-ad/
Datepicker on opening highlights today's date
Datepicker not limiting values correctly to dates in the future
As role Native Nanny, you can now click the Ad icon in the menu and "Place a Nanny Ad".
6) Post Form - New Nanny Ad
<site_url>/en/place-a-nanny-ad/
Datepicker on opening highlights today's date
Datepicker not limiting values correctly to dates in the future
Code being used in 5) and 6):
jQuery(window).bind("load", function() {
jQuery( ".js-wpt-date" ).datepicker("option", "minDate", "0");;
});
To edit your Job Ad: <site_url>/en/my-job-ads/ ... click "Edit Job Ad" on an existing Ad
7) Post Form - Edit Job Ad
Field value shown correctly on loading the edit form
Datepicker highlights correct date value from the database on loading the datepicker
Datepicker limits values correctly to dates in the future
To edit your Nanny Ad: <site_url>/en/my-nanny-ads/ ... click "Edit Nanny Ad" on an existing Ad
8) Post Form - Edit Nanny Ad
Correct field value flashes quickly then today's date is displayed instead
Datepicker highlights date of today instead of the value from the database on loading the datepicker
Datepicker limits values correctly to dates in the future
Code being used in 7) and 8) is same so it is curious that it works on one edit form but not the other:
jQuery(document).on('cred_form_ready', function(){
jQuery('.js-wpt-date').each(function() {
val = jQuery(this).val();
jQuery(this).datepicker("option", "minDate", "0").datepicker("option", "dateFormat", 'dd/mm/yy');
jQuery(this).datepicker("setDate", new Date(val));
});
});
Again, we need all these 8 cases to work correctly, both in New and Edit modes, always showing the correct date from the database where appropriate and always limiting the datepickers accordingly.
Kind regards
Simon