I usually add a class to the fields i want to validate, the same rule could be applied for what you want to do..
<input type="text" class="req" name="forename" value="Forename.." />
<textarea name="comments" class="req">Comments..</textarea>
and the jQuery
$(".inputfield").each(function(index,element){
form.append(element);
//form.attr("input:text",$(element).val());
});
Example
HTML
<form action="scripts/addtocart.php" target="post_requests" enctype="multipart/form-data" type="post">
<input type="hidden" name="price" class="inputfield" value="<?php echo $price; ?>" />
<input type="hidden" class="inputfield" id="product" name="product" value="<?php echo $_GET['id']; ?>"/>
<input type="hidden" class="inputfield" id="sid" name="sid" value="<?php echo $_GET['sid']; ?>"/>
<input type="hidden" class="inputfield" id="hiddenvalue" name="label" value=""/>
<input type="hidden" class="inputfield" id="quantity" name="quantity" value="1"/>
<input type="hidden" class="inputfield" id="labelquantity" name="labelquantity" value=""/>
<input type="hidden" class="inputfield" id="userlabel" name="userlabel" value=""/>
<input type="hidden" class="inputfield" id="colourlabel" name="colourlabel" value=""/>
<input type="hidden" class="inputfield" id="foillabel" name="foillabel" value=""/>
<input type="submit" />
</form>
<iframe name="post_requests" style="display:none;"></iframe>
<div id="response">
Waiting for form to be posted..
</div>
Javascript
function postResponse(_html)
{
document.getElementById('response').innerHTML = _html;
}
scripts/addcart.php
<script type="text/javascript">
var _html = 'The form was posted..';
parent.postResponse(_html);
</script>