Skip to content Skip to sidebar Skip to footer

Onchange On Date Inputs

Possible Duplicate: What events does an fire when it's value is changed? I have a date input field In webk

Solution 1:

You could store the value in a global and check for a difference onclick.

<input type="date" name="myDate" id="myDate" />

var myApp = {};
myApp.myDate = "";

document.getElementById('myDate').onclick = function (e) {
    if (this.value != myApp.myDate) {
        // run onchange code// then set last value to current value
        myApp.myDate = this.value;
    }
};

See example →

EDIT: Or, duplicate question, like comments suggest. (See oninput event)

Post a Comment for "Onchange On Date Inputs"