JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>
<textarea style="display:none" id="template">
<tr>
<td class='type'>Origem: <select size=1 name="item-tipo-{0}">
<option value='1'>Indicador</option>
<option value='2'>Remessa Especial</option>
<option value='3'>Outros</option>
</select>
</td>
<td class='type'>Obra: <select size=1 name="item-obra-{0}">
<option value='905'>905 - Manutenção</option>
<option value='909'>909 - Ligações/Religações</option>
</select>
</td>
<td class='quantity'>Qtd: <input maxlength=7 size=7 class="quantity" min="1" id="item-quantity-{0}" name="item-quantity-{0}" />
</td>
<td><a href="#" id="remove">Remover</a></td>
</tr>
</textarea>
<form id="orderform" class="cmxform" method="POST" action="teste.html">
<fieldset>
<legend>Relação dos Hidrômetros</legend>
<table id="orderitems">
<tbody>
</tbody>
<tfoot>
<tr><td colspan="5"><a href="#" id="add">Adicionar</a></td></tr>
<tr>
<td><input class="submit" type="submit" value="Submit"/></td>
</tr>
</tfoot>
</table>
</fieldset>
</form>
JavaScript
$.validator.setDefaults({
submitHandler: function() {
alert("enviado!");
}
});
$.validator.messages.min = jQuery.format("Deve conter somente números!");
$.validator.addMethod("quantity", function(value, element) {
return !this.optional(element);
}, "Informe a quantidade de HDs");
$().ready(function() {
$("#orderform").validate({
errorPlacement: function(error, element) {
error.appendTo(element.parent().next());
}
});
var template = jQuery.format($("#template").val());
function addRow() {
$(template(i++)).live().appendTo("#orderitems tbody");
}
var i = 1;
addRow();
$("#add").click(addRow);
$("#remove").live('click',function(){
$(this).parent().parent().remove();
});
});