使用javascript获取日期字段值

时间:2014-09-01 11:27:59

标签: c# javascript

我在我的表单中使用sharepoint日期,我试图使用javascript获取日期字段。但我没有得到任何东西。

从f12我得到了这个输入元素

<input name="ctl00$PlaceHolderMain$ArticleDateSection$ctl01$ArticleDateField$ctl00$ctl00$DateTimeField$DateTimeFieldDate" type="text" value="9/10/2014" maxlength="45" id="ctl00_PlaceHolderMain_ArticleDateSection_ctl01_ArticleDateField_ctl00_ctl00_DateTimeField_DateTimeFieldDate" title="Article Date" class="ms-input" autopostback="0">

和我的代码

if (document.getElementById("<%=ArticleDateField.ClientID %>").value="") {
        alert("Please enter the Date..!!")

        document.getElementById("<%=ArticleDateField.ClientID%>").focus();
        return false;
}
你可以告诉我这是什么问题。

是否有其他方法可以获取日期字段。

1 个答案:

答案 0 :(得分:1)

使用as,您缺少=

 if (document.getElementById("<%=ArticleDateField.ClientID %>").value == "") {