DatePicker Not Submitting to database

Hi all!

I’ve set up a custom form with code and all fields submit to database onclick, except the date picker input. I also have the onclick function to disable button if all fields are not complete and that works fine for all inputs, except the datepicker input.

I’ve tried renaming the datepicker id and also tried deleting and adding another but same problem persists. Is this a bug?? … datepicker5 is the problem. The element id is “datepicker5”. Any help would be so appreciated as everything seems in proper order and all other elements and onclick functions accordingly, except for datepicker5. Here’s my code:

export function button118_click(event) {
if (wixUsers.currentUser.loggedIn) {
if ($w( “#input30” ).value !== ‘’ && $w( “#dropdown31” ).value !== ‘’
&& $w( “#dropdown30” ).value !== ‘’ && $w( “#dropdown32” ).value !== ‘’
&& $w( “#datepicker5” ).value !== ‘’ && $w( “#timePicker5” ).value !== ‘’ )

    $w( "#slideshow4" ).changeSlide( 1 ); 

} else {

$w( '#button118' ).disable(); 
        $w( "#text370" ).show(); 

setTimeout ( **function**  () 
    { $w( '#button118' ).enable(); 
        $w( "#text370" ).hide(); 
    }, 3000 );  

wixUsers.promptLogin( { “mode” : “signup” } )
$w( ‘#text319’ ).scrollTo();
} if ($w( “#input30” ).value !== ‘’ && $w( “#dropdown31” ).value !== ‘’
&& $w( “#dropdown30” ).value !== ‘’ && $w( “#dropdown32” ).value !== ‘’
&& $w( “#datepicker5” ).value !== ‘’ && $w( “#timePicker5” ).value !== ‘’ )
$w( “#slideshow4” ).changeSlide( 1 );
else {

$w( '#button118' ).disable(); 
        $w( "#text370" ).show(); 

setTimeout ( **function**  () 
    { $w( '#button118' ).enable(); 
        $w( "#text370" ).hide(); 
    }, 3000 ); 
} 

}

export function button116_click(event) {
if ($w( “#input31” ).value !== ‘’ && $w( “#dropdown32” ).value !== ‘’
&& $w( “#input34” ).value !== ‘’ && $w( “#input35” ).value !== ‘’ ) {

$w( "#slideshow4" ).changeSlide( 2 ); 
    $w( '#dataset1' ).onReady(sendFormData); 

function sendFormData() {
const subject = ${$w( "#input36" ).value} Service Scheduled ${$w( "#input31" ).value} + ${$w( "#input32" ).value};
const body = Thank You For Your Coosing Our Garage, ${$w( "#input31" ).value} \rCustomer Login For Full Details @: ${ "www.autorepairmechanic.shop" } \rCustomer Name: ${$w( "#input31" ).value} + ${$w( "#input32" ).value} \rCustomer Email: ${$w( "#input33" ).value} \rCustomer Tel No: ${$w( "#input34" ).value} \rScheduled Date: ${$w( "#datepicker5" ).value} \rScheduled Time: ${$w( "#timePicker5" ).value} \rVehicle Type: ${$w( "#dropdown30" ).value} + ${$w( "#dropdown31" ).value} + ${$w( "#input30" ).value} \rGarage Contact Information: ${$w( '#dynamicgarageinfo' ).text};
const recipient = $w( “#input33” ).value;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));

sendEmail(subject, body)
.then(response => console.log(response));

}

let vehiclediagnose = {
“title” : wixUsers.currentUser.id,
“vehicleMake” : $w( “#dropdown31” ).value,
“vehicleModel” : $w( “#input30” ).value,
“vehicleYear” : $w( “#dropdown30” ).value,
“whatVehicleNeeds” : $w( “#dropdown32” ).value,
“date” : $w( “#datepicker5” ).value,
“time” : $w( “#timePicker5” ).value,
“firstName” : $w( “#input31” ).value,
“lastName” : $w( “#input32” ).value,
“email” : $w( “#input33” ).value,
“telNo” : $w( “#input34” ).value,
“admin” : $w( “#text372” ).text,
“address” : $w( “#input35” ).value,
“city” : $w( “#input36” ).value,
“shopAddress” : $w( ‘#dynamicgarageinfo’ ).text,
“vehicleType” : $w( “#dropdown30” ).value + ( ’ ’ ) + $w( “#dropdown31” ).value + ( ’ ’ ) + $w( “#input30” ).value,
“fullName” : $w( “#input31” ).value + ( ’ ’ ) + $w( “#input32” ).value,

};

console.log( "vehiclediagnose to be saved"  + JSON.stringify(vehiclediagnose)); 

wixData.insert( "VehicleDiagnose" , vehiclediagnose) 
.then( (results) => { 

let title = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(title));
let vehicleMake = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(vehicleMake));
let vehicleModel = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(vehicleModel));
let vehicleYear = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(vehicleYear));
let whatVehicleNeeds = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(whatVehicleNeeds));
let date = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(date));
let time = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(time));
let address = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(address));
let firstName = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(firstName));
let lastName = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(lastName));
let telNo = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(telNo));
let email = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(email));
let admin = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(admin));
let city = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(city));
let shopAddress = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(shopAddress));
let vehicleType = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(vehicleType));
let fullName = results; //see item below
console.log( "vehiclediagnose in db: " + JSON.stringify(fullName));

    }); 

} else {
$w( ‘#button116’ ).disable();
$w( “#text368” ).show();

setTimeout ( **function**  () 
    { $w( '#button116' ).enable(); 
        $w( "#text368" ).hide(); 
    }, 3000 ); 
} 

}

Thank You

If any other field is empty the button disables. If dataepicker is empty it still submits. Every other field submits to database. If datepicker has a value it does not submit in database field (field key “date”) . Any ideas or is this a bug?

Any help would be much appreciated. I have 2 other forms set up in the same way on the same page that work perfectly. This form also works except fot the date picker. Why is this datepicker not submitting the value?

It is not connected to dataset and submitted entirely through code, but won’y submit value. Anyone have any ideas?

Thanks again

Any suggestions anybody, I’ve checked dataset read and write I’ve checked permissions. All is correct. What could possibly be the issue besides a bug? Anybody can shed some light on this one :slight_smile: Thanks!

I dont have an answer, sorry, but I too am having an issue with the date-picker. It only seems to return a text value to the submission/content manager, even though the field in the content manger is set to receive a date. Losing my marbles over this - any ideas ?

Hi Stephen,
Is this a recent issue or have you always experienced this problem? Can you please share the URL for your site? Thanks.

Its always happened (though I am relatively new to Wix and this is first time I have used a date-picker in a form, so it has never worked for me).

URL is https://aberfoylegolfclub.wixsite.com/my-site-1 - date-picker is on a form on a lightbox. Trigger lightbox by clicking “Submit a new event” which is in the red “Whats on Next” section on the home page.

I tried to get round this by writing code which takes the date string and converts it to UTC date format. This works on preview mode but not on the live page for some reason.

Sure I’m missing something obvious - I would have thought the default output value would be in UTC date format, not a string? Any help much appreciated

Just to add, the date field in the Collection which the form is contributing to is set as a date and time field. So it is obviously kicking out an error message in the collection because the date value which the form is trying to add is a string, not a date. Many thanks

Hi Stephen,
Thanks for your patience. The issue seems to be related to our performance rollout. Can you please check and see if the issue is now resolved? Thanks!

that seems to be giving me a date format now - many thanks. was it just a bug ? kinda surprised you guys would have unfound bugs like that?

As I wrote it anyway, heres some code for anyone that ever wants to turn a string to date format :

// CHANGE DATE TEXT TO DATE OBJECT
wixData.query( “support01” )
.find()
.then( (results) => {
return results.items
})
.then((json) => {
for ( let i = 0 ; i < json.length; i++) {
if ( typeof json[i].dateField === ‘string’ ){
json[i].dateField = newDate(json[i].dateField)
wixData.update( “support01” , json[i]);
}
}
})
. catch ( (err) => {
let errorMsg = err;
});

function newDate(dateField){
var monthNo
var day
let month = dateField.slice( 0 , 3 )
if (Number(dateField.slice( 4 , 6 )) > 9 ){
day = Number(dateField.slice( 4 , 6 ))
} else {
day = Number(dateField.slice( 4 , 5 ))
}
let year = Number(dateField.slice(- 4 ))
switch (month) {
case “Jan” :
monthNo = 0 ;
break ;
case “Feb” :
monthNo = 1 ;
break ;
case “Mar” :
monthNo = 2 ;
break ;
case “Apr” :
monthNo = 3 ;
break ;
case “May” :
monthNo = 4 ;
break ;
case “Jun” :
monthNo = 5 ;
break ;
case “Jul” :
monthNo = 6 ;
break ;
case “Aug” :
monthNo = 7 ;
break ;
case “Sep” :
monthNo = 8 ;
break ;
case “Oct” :
monthNo = 9 ;
break ;
case “Nov” :
monthNo = 10 ;
break ;
case “Dec” :
monthNo = 11 ;
break ;
}
let newDate = new Date(year, monthNo, day)
return newDate
}

@marlowe-shaeffer I thought it was working, but it still isnt. I still get a string value from the date-picker. Also, my ‘workaround’ code below works on preview mode but doesnt seem to work on live website. Any idea why that would be ?

@aberfoylegolfclub Hi Stephen, thanks for letting us know. I got a 404 error from the URL above.
Did you mean this site? https://digitalreset.wixsite.com/aberfoylegolfclub?
If not, please share a working URL so that we can investigate. Thank you.

@marlowe-shaeffer - no, its this one (I moved it yesterday). https://digitalreset.wixsite.com/gartmorevillage
See my earlier post re where datepicker is on home page

@aberfoylegolfclub Hi again, yes, it looks like we were looking at the wrong site. Can you please check and see if the issue is now resolved for Gartmore Village? Thanks.

Hi Stephen, Is the issue now resolved? Please let us know as soon as you can. Thanks!

@marlowe-shaeffer I’m afraid not, still a string - see TEST item below

@Marlowe (Wix) - any resolution yet ?

@marlowe-shaeffer any resolution yet?

@aberfoylegolfclub Are you using the Wix Forms app and not Velo/Data? Please provide all relevant information so we can recreate the problem, including steps to reproduce. Thanks.