Hello,

I need to show the date picker in an input field that is inside a form. I have index.php which has the code for the date picker, I just need to link it to the input field. I have the form in another file as follows:

<form id="inputArea" action="index.php?action=login" method="post">
<input type="text" name="datepicker" value="<?php echo $array['date'];?>"/>
<label for="date">Date of Birth (mm-dd-yyy):</label>
</form>

the code for the datepicker in index.php is:

<script type="text/javascript">

$(document).ready(function() {

	var $datepicker = $( '#datepicker' );

		$datepicker.datepicker({
			
			changeMonth: true,
			changeYear: true
		});
	});
	
	</script>

Thsnks

Hi,

It's not working because your selector doesn't exist:

$('#datepicker'); // This means an element with id="datepicker"
$('input[name=datepicker]');  // This means an input element with name="datepicker"

To resolve, change your selector, or add an id attribute of datepicker to your input field.

R.

Thank you very much the second one worked for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.