I am trying to add some validation rules on an input created from html literals.
This is my fiddle: http://jsfiddle.net/idoxobi/HW4xY/1/
Html:
<form id='form' method='post' >
<div id='details'>
</div>
<a id='Add' href='javascript:void()'>Add</a>
<br />
<input type='submit' />
</form>
JavaScript:
$(document).ready(function() {
$('#form').validate();
var input = "<input type='text' class='item' name='item' />";
$('#Add').click(function() {
$('#details').append(input+'<br />');
$('#details input:last').rules('add', {
required: true
});
});
})
It seems to recognize the rule just in the first element, but the others pass without validation.
Is the first time I use this plug-in, but in the forums everyone says this should work just fine.
Any suggestions?