title: How can I show codeigniter form validation messages in an alertbox
body: <p>I am trying to adapt Ion auth to work with ajax, because my login form is a fixed size, i want to alert the error messages when a form is submitted with incorrect data.</p>
  
  <p>The messages are returned from the controller like this:</p>
  
  <pre><code>$this-&gt;session-&gt;set_flashdata('message', $this-&gt;ion_auth-&gt;messages());
  </code></pre>
  
  <p>and picked up in the view like this:</p>
  
  <pre><code>&lt;div id="infoMessage"&gt;&lt;?php echo $message;?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I am trying to display them as follows:</p>
  
  <pre><code>&lt;?php   if((isset($message))&amp;&amp;($message!='')){
              echo '&lt;script&gt; alert("'.$message.'"); &lt;/script&gt;';
          }
  ?&gt;
  </code></pre>
  
  <p>This isn't working, the alert is not being displayed, I have removed the message delimiters but this didn't help. My only thought is it must be something to do with the way codeigniter is creating a new line in the middle of my javascript as it is coming out like this:</p>
  
  <pre><code>&lt;script&gt;
  alert('The Identity field is required.
  The Password field is required.');
  &lt;/script&gt;
  </code></pre>
  
  <p>How can I get rid of this newline and replace it in a way that wont break my js?</p>