Setting the value of Datepicker from a hidden field
I have a page that has a repeating form each of which shows a date (via datepicker). In the same form is a hidden field which should serve as the minDate for the datepicker.
Try as I might, I can't figure out how to get the value of the hidden sibling into the minDate. I'm pretty sure the problem I'm having is from not properly selecting the hidden field.
If I set the minDate literally to "04/28/2015" ("minDate:04/28/2015") it works as expected. But, if I use the code below, though the control shows up, the mindate does not seem to be set.
Here is the content of the form:
<form style="margin:0";> |
|
|
|
<input type="hidden" name="StylePatternColor" class="StylePatternColor" value="Bel Air" /> |
|
<input type="hidden" class="PromiseDate" name="PromiseDate" value="04/26/2015" /> |
|
<input class="date" name="ShipDate" id="ShipDate0" value="04/28/2015" /> |
|
<input type="hidden" name="Key" value="0" /> |
|
|
|
</form> |
Can somebody please point me in the right direction?
jQuery(function($) {
$(".date").datepicker({
minDate: $(this).siblings('.PromiseDate').val(),
onSelect: function(dateText) {
var $form = $(this).closest('form'); // get the form element this button belongs to
var theData = $form.serialize(); // generates the data string
//
alert(theData);
var newVal = "Dummy";
$.ajax({
type: "GET",
url: "cartDateUp.php?newvalue=" + newVal + "&" + theData,
success: function(data,status){
//$button.parent().find("input").val(newVal);
}
});
}
})
});