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
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 }
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?
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
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
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 ?
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?