Javascript and php quotations preventing the execution of functions
<p>I am trying to construct a registration form using the code below, I am still in the beginning phase. I am having a really difficult time executing any of the JavaScript code that is within the PHP echo statement.</p>

<p>I tried escaping the single and double quotes within the javascript functions using the slash <code>\'</code> and <code>\"</code>, which worked for the top javascript function, but once I added the other two functions and applied the same logic, all javascript functions stopped working.</p>

<p>Can someone please advise what is the easiest way to prevent problems and easily execute javascript code that is within a php echo statement?</p>

<pre><code>&lt;?php

echo '
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;      
    &lt;script type="text/javascript"&gt;
        function validateEmail(email) { 

            var re = /^(([^&lt;&gt;()[\]\\.,;:\s@\"]+(\.[^&lt;&gt;()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

            if(re.test(email)) {
                document.getElementById(\'result\').innerHTML = \'&lt;img src=\"http://www.customotion.com/green_check_small.png\" style=\"width:15px;\"/&gt; Valid\';
            } else {
                document.getElementById(\'result\').innerHTML = \'&lt;img src=\"http://biglistbigsales.com/m/templates/GPT/images/x_xMarkRed4.png\" style=\"width:15px;\"/&gt; Invalid\';
            }
        }   

    &lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div id="main-container"&gt;

&lt;div id="body-container" style="padding-bottom:150px; height:800px;"&gt;
    &lt;div style="height:100px; margin:0px auto;"&gt;
        &lt;img class="reg-step" style="width:100%;" src="images/step1.png"&gt;
    &lt;/div&gt;
    &lt;div style="margin-left:110px;"&gt;
        &lt;span style="font-size:24px;" class="smallheading"&gt;Tell Us About Yourself&lt;/span&gt;
        &lt;br/&gt;&lt;span style="font-size:13.5px;"&gt;&lt;i&gt;*All fields required&lt;/i&gt;&lt;/span&gt;
    &lt;/div&gt;

    &lt;form method="post" action="registernew.php"&gt;
    &lt;div style="margin:0px auto; margin-left:110px; border:1px solid blue; float:left; font-size:12px; width:500px;"&gt;
        &lt;div style="border:1px solid blue; float:left; width:80%;"&gt;
            &lt;div style="float:left; border:1px solid red;"&gt;
                First Name:
                &lt;br/&gt;&lt;input type="text" style="width:140px;" name="fname" /&gt;
            &lt;/div&gt;

            &lt;div style="float:right; margin-right:50px; border:1px solid red;"&gt;
                Last Name:
                &lt;br/&gt;&lt;input type="text" style="width:140px;" name="lname" /&gt;
            &lt;/div&gt;
        &lt;/div&gt;

        &lt;div style="border:1px solid blue; float:left; margin-top:20px; width:50%;"&gt;
            &lt;div style="float:left; border:1px solid red;"&gt;
                City:
                &lt;br/&gt;&lt;input type="text" style="width:170px;" name="fname" /&gt;
            &lt;/div&gt;
            &lt;div style="float:right; border:1px solid red;"&gt;
                State:
                &lt;br/&gt;';
                include('inc/statedropdown.inc.php');
echo'       &lt;/div&gt;
        &lt;/div&gt;
        &lt;div style="float:left; width:100%;"&gt;
            &lt;br/&gt;Company Name:&lt;br/&gt; &lt;input type="text" name="fname" style="width:150px;"/&gt;
            &lt;br/&gt;&lt;br/&gt;E-mail Address:&lt;br/&gt; e-mail:&lt;br/&gt;&lt;input id="email" type="text" onblur="validateEmail(this.value)" /&gt;&lt;span id="result"&gt;&lt;/span&gt;
            &lt;br/&gt;&lt;br/&gt;Phone Number:&lt;br/&gt; &lt;input type="text" name="fname" style="width:110px;" /&gt;
            &lt;br/&gt;&lt;br/&gt;Password:&lt;br/&gt;&lt;input type="password" name="fname" /&gt;
            &lt;br/&gt;&lt;br/&gt;Confirm Password:&lt;br/&gt;&lt;input type="password"  name="lname" /&gt;

            &lt;br/&gt;&lt;input type="submit" value="Next Step" style="background-color:#ebda5f; color:blue; margin:15px 0px 0px 20px;"&gt;
        &lt;/div&gt;
    &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;';

?&gt;
</code></pre>
