CFv3.2
I've been for a couple of days now and can't seem to find how one can add validation for radio buttons dynamically.
In short I have a radio button which lets you choose between "Video" or "Poster"
When you choose "Video" the field "Upload Video" is required.
When you choose "Poster" you will need to choose one option from a group of radio buttons and it's also required.
So the "Upload Video" is only required when you have chosen "Video".
And you must select one of the "Poster" radio buttons when "Poster" was choosen in the first radio button.
I'm able to do it for the "Upload Video" with .add(Prescence) but I can't find out how to do it for the radio buttons.
Here you see how it looks.

I've also uploaded the form.
Here is the HTML part:
<div class="form_item">
<div class="form_element cf_radiobutton">
<label class="cf_label" style="width: 150px;">Video or Poster</label>
<div class="float_left">
<input value="Upload video" title="" class="radio validate-one-required" id="video_or_poster1" name="video_or_poster" type="radio" />
<label for="video_or_poster1" class="radio_label">Upload video</label>
<br />
<input value="Choose a poster" title="" class="radio validate-one-required" id="video_or_poster2" name="video_or_poster" type="radio" />
<label for="video_or_poster2" class="radio_label">Choose a poster</label>
<br />
</div>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_fileupload">
<label class="cf_label" style="width: 150px;">Upload video</label>
<input class="cf_fileinput cf_inputbox" title="" size="20" id="uploadvideo" name="uploadvideo" type="file" />
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_radiobutton">
<label class="cf_label" style="width: 150px;">Choose Poster</label>
<div class="float_left">
<input value="Poster 1" title="" class="radio" id="poster1" name="poster" type="radio" />
<label for="poster1" class="radio_label">Poster 1</label>
<br />
<input value="Poster 2" title="" class="radio" id="poster2" name="poster" type="radio" />
<label for="poster2" class="radio_label">Poster 2</label>
<br />
<input value="Poster 3" title="" class="radio" id="poster3" name="poster" type="radio" />
<label for="poster3" class="radio_label">Poster 3</label>
<br />
</div>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_button">
<input value="Submit" name="button_3" type="submit" />
</div>
<div class="cfclear"> </div>
</div>
Here is the JavaScript part.
window.addEvent('domready', function() {
var fileupload = new LiveValidation('uploadvideo');
fileupload.add( Validate.Presence );
var poster = new LiveValidation('poster');
poster.add( Validate.Presence );
var uploadcheck = function() {
if ( $('video_or_poster1').checked == true ) {
fileupload.enable();
poster.disable();
}
if ( $('video_or_poster2').checked == true ) {
fileupload.disable();
poster.enable();
}
};
$('video_or_poster2').addEvent('change', uploadcheck);
$('video_or_poster1').addEvent('change', uploadcheck);
});
This part is not working. I suspect because it needs validate-one-required instead of required.
var poster = new LiveValidation('poster');
poster.add( Validate.Presence );
and of course this won't work either:
poster.enable();
I really can't find how to make this work.
Please advice.
Regards,
SaGo