如何从html文本框中选择日期是-Date

时间:2015-02-25 09:41:29

标签: javascript jquery html

我试图从两个日期得到差异.. 我使用的是html is-Date文本框

<input type="text" name="datein" id="datein" value="" class="inputtexbox datepicker"   style="display: none" is-Date/> 
<input type="text" name="dateto" id="dateto" value="" class="inputtexbox datepicker" style="display: none" is-Date/>


<script>
    alert(document.getElementById("datein").value);
    alert(document.getElementById("dateto").value);
</script>

我试图将这些值添加到java脚本中以进行比较。但警报是空的

1 个答案:

答案 0 :(得分:1)

在输入值

后应该调用警报

值为空 - &gt; value=""

试试这个:

<input type="text" name="datein" id="datein" value="123" class="inputtexbox datepicker"   style="display: none" is-Date/>
<input type="text" name="dateto" id="dateto" value="543" class="inputtexbox datepicker" style="display: none" is-Date/>
<button onclick="alertInputs()">Show Inputs</button>

<script>
    function alertInputs() {
        alert(document.getElementById("datein").value);
        alert(document.getElementById("dateto").value);
    }
</script>