x

Datepicker in Contact Form

A datepicker code would be very useful to embed in a contact form. This one works in Weebly - sends an email with all the fields BUT it doesn't send the date picked.   Any ideas?

  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <script>
  $(function() {
    $( "#datepicker" ).datepicker({
    minDate: new Date(),    // prevent selection of date older than today
    autoSize: true,         // automatically resize the input field
    dateFormat: 'DD, d MM yy',  // Date Format used
    firstDay: 1 // Start with Monday
    });
  });
  </script> 
<p>Please select a Date</p>
<input id="datepicker" class="wsite-form-input wsite-input" type="text" name="datepicker" />

5,868 Views
Message 1 of 12
Report
11 REPLIES 11

Why would your even want to use the Weebly contact form? When you can use Vcita it looks better, gets peeps attention, and yes it does work and I have the heat map to prove it. Smiley Wink

5,863 Views
Message 5 of 12
Report

Thanks but not interested in forking over additional $$$.  Trying to keep things simple by embedding a code into the contact form to make it easy for the client to choose an arrival date.  

5,851 Views
Message 5 of 12
Report
Square

Our backend scripting probably lacks any code to handle a field added through client-side scripting like that. We have some other form options in our App Center:

https://www.weebly.com/app-center/search/contact

I'm not sure if any of those include a date picker, but they're worth checking out.

5,841 Views
Message 5 of 12
Report

For anyone in the future... The trick would be to add a regular drag and drop text field through the weebly interface.. then add the datepicker field as you did.

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <script>
  $(function() {
    $( "#datepicker" ).datepicker({
    minDate: new Date(),    // prevent selection of date older than today
    autoSize: true,         // automatically resize the input field
    dateFormat: 'DD, d MM yy',  // Date Format used
    firstDay: 1 // Start with Monday
    });
  });
  </script> 
<p>Please select a Date</p>
<input id="datepicker" class="wsite-form-input wsite-input" type="text" name="datepicker" />

Then you would need to use jquery to copy the value of the datepicker field into the regular text field whenever someone selects a date. That will save the date into the backend. Final code block below -- be sure to swap out the id used for the id of the text field we added before adding this code block. (see comments in code)

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker({
minDate: new Date(), // prevent selection of date older than today
autoSize: true, // automatically resize the input field
dateFormat: 'DD, d MM yy', // Date Format used
firstDay: 1, // Start with Monday
onSelect: function(dateText, inst) {
var date = $(this).val();
$("#input-30571982367218956").val(date); //use the id of the text field we added through the weebly interface.
}
});
});

</script>
<p>Please select a Date</p>
<input id="datepicker" class="wsite-form-input wsite-input" type="text" name="datepicker" />
<br>
<br>
<style>
#input-305719823672189561 {
display:none !important;
}
</style>

hope that helps!

4,880 Views
Message 13 of 12
Report
Square

Thanks for sharing, @BenSlight!

4,876 Views
Message 13 of 12
Report

Much easier (for your paying customers) if you guys get busy with dev and give us a Date Picker in Weebly. What on earth is the matter that this hasn't been delivered? People are asking you for this for the last few years and all you do is archive it off??? Its hardly a large piece of work, and its a basic on a form these days. Using a short text field is no good as customers can bypass it by just entering a single character and we lose valuable info on a date that is required. Come on Weebly, wake up please.

Thanks !

4,136 Views
Message 13 of 12
Report

Totally agree, why hasn't this simple functionality been implemented yet? Essential for even a basic website builder!

3,954 Views
Message 13 of 12
Report

I need a date picker in the contact form !! 

3,856 Views
Message 13 of 12
Report
Square

Thanks for your feedback, @Durga. The date picker is not an option for the Weebly contact form, but you should be able to embed a third party calendar with the Embed Code element if you like. 

3,850 Views
Message 13 of 12
Report

Hi, 

Apologies if I am being a klutz but I've dropped the final string into a Weebly embed code box and whilst it is now displaying a drop-down calendar on the live site, I don't have an id to update the validation? 

Thanks for your help...

Damian

1,222 Views
Message 13 of 12
Report

This added the date in the text field but now my contact form does not work. When I click Submit I never receive the entry. Without the code the form works fine though... Any help?

1,054 Views
Message 13 of 12
Report