The values of the select, the input and the names of the selected
checkboxes are added to a string and added to the unordered list as:
<li>Input Values</li>
If the select is empty and the input is empy I want to display the
error message and the items not added. Here is my code:
// Define remove event
$('.Remove').livequery('click', function(event) {
$(this).parent().remove();
});
// Create fields
var subject = [], note = [], levels = [];
// Bind add button
$('#AddTheme').bind('click', function(){
// Define fields
subject = $('#Subject option:selected').text();
note = $('#Note').val();
levels = $('input:checked + label').map(function() {
return $(this).text();
}).get().join(", ");
// Define data
var data = subject + '.' + note + '.' + levels;
// Append theme
$('<li class="DynamicList"></li>').appendTo('#Themes')
.append(subject)
.append('<br />')
.append(levels)
.append('<br />')
.append(note)
.append('<br />')
.append(' <a href="#Remove" class="Remove">Remove</a>')
.append(' <input type="hidden" name="Themes" value = "' + data
+ '" />');
});
I can integrate the validation in my script but since I am using
Validate if it would be possible I would handle the validation all in
the same way.
Thanks,
Miguel
On Oct 27, 10:11 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Whats supposed to happen when you click the add button?
>
> Jörn
>
> On Mon, Oct 27, 2008 at 10:54 PM, shapper <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I have a form with 20 elements a Submit Button and a Validate. It
> > works fine ...
>
> > Inside this form I added the following:
> > - a select, an input and 3 checkboxes all with same name;
> > - a button named Add;
> > - an ordered list.
>
> > When the Add button is clicked the values of the select, input and
> > checkboxes are added to the list as list item.
> > Note: When the Add button is clicked it does not submit the entire
> > form
>
> > $('#Add').bind('click', function(){
> > // logic done here
> > }
>
> > Can I add validation functionality to Add button using the validate
> > plugin?
>
> > The select and the input should be required.
>
> > Note: when the entire form is submitted these fields can be empty
>
> > Thanks,
> > Miguel