0

Why is it when i have this format for datepicker, a from submits correctly

$(function() {
$( "#datepicker" ).datepicker({
inline: true, 
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
dateFormat: 'yy-mm-dd'
});
});

but as soon as i use the following date format

$(function() {
$( "#datepicker" ).datepicker({
inline: true, 
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
dateFormat: 'dd-mm-yy'
});
});

the form does not submit, instead it opens the datepicker calender again. All i have done is changed the dd and yy around.

All of the scripts on the page

$(document).ready(function() {
<?
if ($Fchk===1) {
?>
$('#newCus').show();
$('#delivery').hide();
$('#sDel').show();
<?
} else {
?>
$('#newCus').hide();
$('#delivery').hide();
$('#sDel').hide();
<?
}
?>
$('#seldate').hide();
$('seldelopt').show();

$("#ncus").validate({
debug: false,
submitHandler: function(form) {
  $.post('order_new.php', $("#ncus").serialize(), function(data) {
    $('#mainBody').html(data);
    $("#mainBody").find("script").each(function(i) {
      eval($(this).text());
    });
  });
}

});

    $("#setDel").click(function() {
        if($('#setDel').is(':checked')) {
        $('#delivery').fadeIn('slow')
        } else {
        $('#delivery').fadeOut('slow')
        document.getElementById("delAddress").value = ""
            if ($('#delAddress1').length ) {
            document.getElementById("delAddress1").value = "";
            }
            if ($('#delAddress2').length ){
            document.getElementById("delAddress2").value = "";
            }
            if ($('#delAddress3').length ) {
            document.getElementById("delAddress3").value = "";
            }
            if ($('#delAddress4').length ) {
            document.getElementById("delAddress4").value = "";
            }
        document.getElementById("delTown").value = ""
        document.getElementById("delCounty").value = ""
        document.getElementById("delpostcode").value = "";
        }
    });

    $('input:radio[name="dDate"]').change(function(){
        if($(this).val()==1) {
           alert($(this).val());
        } else {
            $('#seldelopt').fadeOut('fast')
            $('#seldate').fadeIn('fast');           
        }
    });


    $("#enable").click(function() {
        if($('#enable').is(':checked')) { 
        $('select[name="cusID"]').attr('disabled', 'disabled');
        $('#sDel').fadeIn('slow')
        $('#newCus').fadeIn('slow');
        } else {
        $('select[name="cusID"]').removeAttr('disabled');
        $('#sDel').fadeOut('slow')
        $('#newCus').fadeOut('slow')
        }
    });


});




$(function() {
        $( "#datepicker" ).datepicker({
        inline: true, 
        showOtherMonths: true,
        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        dateFormat: 'yy-mm-dd'
        });
    });


    $("#datepicker").click(function() {
        if ($('#datepicker').length ) {
        document.getElementById("datepicker").value = "";
        }
    }); 
Palm Int Srv
  • 43
  • 1
  • 7
  • This might help you... http://stackoverflow.com/questions/1328025/jquery-ui-datepicker-change-date-format – scrowler Oct 21 '13 at 01:34
  • Hi @TusharGupta yes the site is live but it is a customer log in site so I would need to email you some separate credentials to log in with if you wanted to take a look – Palm Int Srv Oct 21 '13 at 02:42
  • Are you sure the new `dateFormat` passes your form validation? – Maksida Oct 21 '13 at 03:24
  • Hi @PeterMichael the only validation is done via the post in jquery. The form posts fine in American format MM DD YY or YY MM DD but when you use dd mm yy and submit the form it just throws up the datepicker and does not post. There must be a simple explanation for this I will add all of the scripts to my original post for you to see – Palm Int Srv Oct 21 '13 at 03:39
  • Works fine: http://jsfiddle.net/rYzcP/. Can you create a [JSFiddle](http://jsfiddle.net/) with all your code? – Maksida Oct 21 '13 at 03:52

1 Answers1

0

Many thnaks for the help given. I found the issue. Where i have posted all of the scripts, On line 3 it says

<?
if ($Fchk===1) {
?>

It should be

<?
if ($Fchk=1) {
?>

So it was a PHP issue and not a jquery issue. Duh how silly do i feel now :)

Palm Int Srv
  • 43
  • 1
  • 7