jQuery Date Picker Input Date Format

http://stackoverflow.com/questions/11104933/jquery-date-picker-input-date-format

by Dhiraj Bodicherla

HTML

<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css">
Normal Field :
<input type="text" placeholder="Name">
<br>
<br>
<br>Shown Field :
<input id="thedate" type="text" placeholder="startdate" />
<br />

JavaScript

$(function () {

    $('#thedate').datepicker({
        dateFormat: 'dd-mm-yy',
        altField: '#thealtdate',
        altFormat: 'yy-mm-dd'
    }).on('focus', function () {
        console.log('haha');
    });

    $('input,textarea').focus(function () {
        if ($(this).prop('placeholder')) {
            $(this).data('placeholder', $(this).prop('placeholder'))
            console.log($(this).prop('placeholder'), $(this).data('placeholder'));
            $(this).prop('placeholder', '');
        }
    });
    $('input,textarea').blur(function () {
        if (!$(this).prop('placeholder')) {
            console.log("adding " + $(this).data('placeholder'));
            $(this).prop('placeholder', $(this).data('placeholder'));
        }
    });

});