1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Change datefield

Discussion in 'JavaScript' started by Johan Buitelaar, Feb 16, 2017.

  1. #1
    Hi all,
    I'm starting to learn Javascript, but I desperately need to adjust a piece of code right now:

    I have this code which trims the date from a 'enddate' box.
    What I want now is to adjust this code so that it returns 'startdate' 17:00 h

    So: I choose startdate = 15-2-2017 08:00
    or even better: I choose startdate 15-2-2017, the code fills the time: 08:00
    enddate auto fills with: 15-2-2017 17:00

    Can anyone make something out of this?
    Thanks!

    var startDate = $('.pss_fieldname_begindatetime input').val().substring(0,$('.pss_fieldname_begind atetime input').val().indexOf(" ")).trim();

    var dateTimeInput = $(this).find("input");
    dateTimeInput.on("focus", function() {
    setTimeout(function(){
    dateTimeInput.datetimepicker({
    datepicker:false
    });
    }, 500);
    });

    var isDisallowedKeycode = function(keycode){
    return (
    ((keycode >= 48) && (keycode <= 90)) || ((keycode >= 96) && (keycode <= 111)) || ((keycode >= 186) && (keycode <= 22))
    );
    }

    dateTimeInput.on("keydown", function(event){
    if (isDisallowedKeycode(event.which)){
    return false;
    }
    });

     
    Johan Buitelaar, Feb 16, 2017 IP