Javascript validation
<p>I have a form that people can click and add fields to the form and I need to have it validate the values in those fields if it is clicked. </p>

<p>So say I click it twice and get the 2 separate sets of fields and I need the rotation % to make sure it equals 100 at the time of save. </p>

<p>I have put in this function to get it to validate on the save and everything works except if I edit a different form that doesnt have any fields in it.<br>
 I am trying to see what the easiest way would be to check and see if the fields are on there or not so I can check them.</p>

<p>Here is my code:</p>

<pre><code>function audit()
{
    var totalsum = 100;
    $( '[name="rotation\\[\\]"]').each(
      function()
      {
        totalsum -= ($(this).val() * 1);
      }
    )
    if(totalsum &gt; 0){
        alert("Your rotation % does not equal 100");
        return false;}
    return true;}
</code></pre>

<hr>

<pre><code>$('.add_creative img').click(
function(){
    $.post( '/json/ad_creative/',
    { action: "add_creative", this_brand_id: $("[name='this_brand_id']").val(), adtype: $( '.new_run [name="adtype"]').val()},
    function(data){
        if( data.result ){
            $('.add_creative').append(data.html)
            }    
        },
        'json'
        )
</code></pre>
