Validate dynamically added form
<p>I am working on a form for people to fill in and wanted to have a checkbox when if checked more forms appeared, this was not an issue but when the forms appear I want to validate them which requires a class="" to be set how can I do this? </p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Show div on check for checkbox&lt;/title&gt;
&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form&gt;
Check me    &lt;input name="checkbox" type="checkbox" id="checkbox" onclick="$(this).is(':checked') &amp;&amp; $('#checked').slideDown('slow')|| $('#checked').slideUp('slow');"

/&gt;


&lt;p id="checked" style="display: none; margin: 10px; height: 100px; background-color: #f5f5f5; padding: 10px" &gt;
&lt;label for="form"&gt;input?&lt;/label&gt;

    &lt;input  class="" type="text" name="form" id="form"&gt;
 &lt;/p&gt;



&lt;script&gt;
$("input.checkbox").click(function(){
        if($(this).is(":checked")){
            $("input.form").addClass("required");
Else
$("input.form").removeClass("required");
        }
    });

&lt;/script&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>This is my code that does not seem to work, when I check the source code before and after its the same.</p>

<p>Az</p>
