title: Javascript Empty field validation - Cannot read property 'value' of undefined
body: <p>I have been researching for days and taken several example from here for a solution to validate a date fields to make sure it is not empty before moving to next page. but keeps getting cannot read property of undefined, and I have tried using Joomla build validate.js which will not work inside this custom component, and I am hoping for some help here to tackle this issue.  </p>
  
  <p>Here's the javascript</p>
  
  <pre><code>nextpage:function(){
  var deliveryy=document.getElementsByName("customPlugin")[0].value;
  
      if(delivery == "" || delivery == null) {
      alert("filled out All Delivery Date &amp; Time"); 
  return false; } else { .........
  </code></pre>
  
  <p>Here's the onclick button</p>
  
  <pre><code>&lt;button type="button" id="productbuilder_next" class="productbuilder_pagination pbbutton btn" onclick="productbuilder.nextpage();"&gt; Next&lt;/button&gt;
  </code></pre>
  
  <p>Here's the raw data of the field I am trying to validate that it is not empty</p>
  
  <pre><code>&lt;input id="&lt;?php echo $class.$rand ?&gt;" class="required &lt;?php echo $class ?&gt;" required="true" type="text" value="" size="&lt;?php echo $this-&gt;params-&gt;custom_size ?&gt;" name="customPlugin[&lt;?php echo $viewData[0]-&gt;virtuemart_customfield_id ?&gt;][&lt;?php echo $this-&gt;_name?&gt;][comment]"&gt;&lt;?php if($this-&gt;params-&gt;custom_populate_alternate_field){?&gt;&amp;nbsp;&lt;input type="text" id="alternate&lt;?php echo $rand?&gt;" size="30"&gt;
  </code></pre>
  
  <p>Generated </p>
  
  <pre><code>&lt;input id="vmcustom-datetime1930516000" class="required vmcustom-datetime hasDatepicker" required="true" type="text" value="" size="10" name="customPlugin[176][datetime][comment]"&gt;
  </code></pre>