title: Sharepoint: How to get date value from DateTimeField on custom form via Javascript/JQuery?
body: <p>I've searched the web for a while, but I couldn't find a simple answer to my question. So, I've got a Sharepoint List, with Date and Time type, and I created a custom form for adding new element's. On the form, I created a DateTimeField just like that:</p>
  
  <pre><code>&lt;SharePoint:DateTimeField runat="server" id="ff_Order_Asset_DeliveryDate" FieldName="DeliveryDate"  /&gt;
  </code></pre>
  
  <p>And everything works just fine. Now i would like to add a validation, becasue selected date can't be in the past, so i need to compare it do current date. I would like to do it in javascript using PreSaveAction, but the problem is, i have no clue how to get date value from my control. I've tried something like this:</p>
  
  <pre><code>var dateSelected = document.getElementById("&lt;%=ff_Order_Asset_DeliveryDate.ClientID%&gt;");
  var dateFromSelection = new Date(dateSelected.value);
  var dateNow = new Date();
  if (dateFromSelection &lt; dateNow)
  doSomething();
  </code></pre>
  
  <p>But of course it doesn't work. Please enlighten me how could i manage to do that? I will be very gratefull!</p>
  
  <p>------------------------------- ANSWER --------------------------------------</p>
  
  <p>If someone care: it seemed that only thing i should have done, is use this jQuery syntax:</p>
  
  <pre><code>var dateSelected = $('input[id*="ff_Order_dFAsset_DeliveryDate"]');
  </code></pre>
  
  <p>beacuse as Mark Oreta said, Sharepoint added much to ID of my control.</p>