Forums

Help with validation

rstevens 13 Sep, 2013
I have a CF V4 form made, but am having trouble with validation. For some reason, I can't get the required field validation to work. And, I need to set up Javascript to require validation if a radio button is selected.

Here is the form...

http://indianasoybean.com/index.php?option=com_chronoforms&chronoform=ResearchReport

Items 1, 2 and 3 are required. Items 4 and 5 are required only if the second radio button is selected. That's it.

Will pay your hourly fee. Thanks.
GreyHead 14 Sep, 2013
Hi rstevens,

You have a couple of JavaScript errors on the page. They both seem to occur because they refer to elements that don't exist in the form.
var textarea = $('outputs');
. . .
var changes = document.getElementById('changes');


Also, to use JavaScript with the form you should add ids to the form elements to make reference simpler.

Bob
rstevens 14 Sep, 2013
Thanks for the quick response. I am buying you another beer.

I do have the correct ids in the code in the custom element in the preview box. Here is the relevant code...

<div class="ccms_form_element cfdiv_textarea" id="outputs_container_div" style=""><label for="outputs"></label>
<textarea name="outputs" id="outputs" rows="10" cols="100">
</textarea>
<div class="small-message">3200 chars max <span id='counter'>3200</span></div>
</div>

<textarea name="changes" rows="10" cols="100">

</textarea>

This isn't the validation problem I referred to for the first three items. I put an Auto Javascript Validation box into the onload events page. And put outputs,outcomes_impacts,publications into the required field. Then saved it.

However, when I submit the new form without filling any of the textareas, I am sent to the thank you page.

So, then I tried using the Auto Server Side Validation, putting the same fields in the required field.

This time I get a pink box at the top of the form saying...

1. This field is required.
2. This field is required.
3. This field is required.

When I submit the form without filling in the textareas, I am sent to the thank you page.
This topic is locked and no more replies can be posted.