Tag Archives: validation

jQuery validation: required and minlength for dynamic fields

This is not a smart way though, but I tried to code for a bit complexed form. Demo. Code snippet: $(’form input[type=button]’).click(function(){ $(’ul’).show().append('<li><input class="hidden" type="checkbox" name="list[]" value="1" checked="checked" />’ + $(’select[name=item_name] option:selected’).html() + ‘&nbsp;’ + $(’select[name=price] option:selected’).html() + ‘&nbsp;<a>remove</a></li>’); $(’ul li a’).click(function(){ $(this).parent().fadeOut(’slow’, function(){ $(this).remove(); }); }); }); var validator = $(’form’).validate({ rules: { ‘list[]’: […]

Posted in Tweak | Also tagged | Comments closed