title: Uncaught TypeError: Cannot read property 'value' of null using joomla
body: <p>this error comes up when using the following :
  field <strong>otherinfo</strong> has id=idOtherInfo and is declared in a <strong>.xml</strong> file under Models, Forms in <strong>joomla</strong>.
  The field has a default value in the declaration to prevent the null (shows the default value in the browser) and using the 
  <code>onchange="dosomething()"</code> 
  I am running a javascript file, which runs ok as it shows an alert and then it halts on the command 
  <code>var first1 = document.getElementById("idOtherInfo").value;</code>
  The javascript file is loaded by </p>
  
  <pre><code>JHtml::script(JURI::root() . 'media/com_hr/js/validateFields.js', true);
  </code></pre>
  
  <p>also can be loaded by</p>
  
  <pre><code>$document = JFactory::getDocument();
  $document-&gt;addScript(JURI::root().'media/com_hr/js/validateFields.js');
  </code></pre>
  
  <p>Can you please help?
  Thanks</p>