Set date on submit

If a form is sent, the current date will be set.

This example shows how to set the current date. If you push the button initially, the form will not be sent, because the onsubmit funtion returns false.

$.xutil.onsubmit = function(valid) {
    var currDate = new Date(); // current client date when you send the form
    $('[name="tfDate"]').val($.datepicker.formatDate("", currDate));
    return false; // have to be the value valid, otherwise the form will not sent


function getDateFormat(date){
    var day = prependNull(date.getDate());
    var month = prependNull(date.getMonth()+1);
    var year = date.getFullYear();
    var time = date.getHours()+':'+date.getMinutes();
    return day+'.'+month+'.'+year+' '+time;


function prependNull(value) {
    return value < 10 ? '0'+value : value;