@kvhrao: Thanks for outlining your solution and breaking it down.
For anyone unsure of where kvhrao is adding his code blocks, read on…
<?php
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
?>
…is added to your child theme’s functions.php file (How to create a WordPress child theme).
<input type="text" id="MyDate" name="MyDate" value=""/>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#MyDate').datepicker({
dateFormat : 'dd-mm-yy'
});
});
</script>
…is added to your page template file (How to create a WordPress page template).
If you want to use more than one datepicker per page, use the following instead of the above second block of code:
<input type="text" class="MyDate" name="MyDate_a" value=""/>
<input type="text" class="MyDate" name="MyDate_b" value=""/>
<input type="text" class="MyDate" name="MyDate_c" value=""/>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.MyDate').datepicker({
dateFormat : 'dd-mm-yy'
});
});
</script>
The only difference is that the id has been changed to a class in the HTML and JavaScript code.
The difference between id and class