HTML5 <input type=“date”>

Is possible to detect in event onChange for <input type=“date”> , when user using graphical calendar and arrows or using keybord number ?

I am only interested solutions in VanillaJS.


像这样?

function handler(e){
  alert(e.target.value);
}
<input type="date" id="dt" onchange="handler(event);"/>

您可以使用两个事件onchange事件,但您的字段应该先初始化:

var date_input = document.getElementById('date_input');
date_input.valueAsDate = new Date();

date_input.onchange = function(){
   console.log(this.value);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="date" id='date_input'>

Yes you can but kindly check support for the browser for date time support

Check the bin for functional example!

JSBin

In case of Chrome the event will not be fired unless the whole date is input!

链接地址: http://www.djcxy.com/p/93984.html

上一篇: 领事服务定义地址和服务地址之间的区别

下一篇: HTML5 <input type =“date”>