How can I validate a sentence using PHP and JavaScript?
<p>I am currently trying to validate if the sentence a user enters matches the expected sentence. The expected sentence is stored in a PHP variable <code>$rebuiltSentence</code>, for example 'the cat sat'.</p>

<p>The problem is that when I try to call my JavaScript function <code>formSubmit()</code> I need to give it the sentence to check, therefore ideally I would call formSubmit($rebuiltSentence). I think this won't work because it thinks it is being passed several separate strings.</p>

<p>Here is what I've got:</p>

<pre><code>//sentence.php

&lt;input type='button' value='Submit' onClick=formSubmit('$rebuiltSentence')
</code></pre>

<p>and</p>

<pre><code>//validate.js
function formSubmit(correct)
{
var contents = document.getElementById('sentenceBuilder').value;
if(contents==correct){

 alert('The Sentences Match');
}else{
 alert('The Sentences Dont Match');
}

window.location.reload(true);
}
</code></pre>

<p>Any ideas how I can solve this?</p>
