Forums

validation with dynamically added fields does not work

markoadams 25 Jan, 2011
I have a form that dynamically adds fields - using the example provided in the thread http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=5&t=15219&start=15#p45751. But I'm stuck on validation: if the fields that are dynamically added have any validation on them then the form simply won't submit. You can see this by comparing 2 test forms on my site: test_addfields (http://dontgetlost.ca/index.php?option=com_chronocontact&chronoformname=test_addfields) does not submit, test_addfields2 (http://dontgetlost.ca/index.php?option=com_chronocontact&chronoformname=test_addfields) submits fine; the only difference is I removed the validation from the dynamic fields for the 2nd form. BUT these should be required fields as well as validated for the right data type. Any idea why these fields are preventing submit?

Thanks

Mark
GreyHead 30 Jan, 2011
Hi Mark,

This is a tricky problem and I'm not sure that there is an easy answer using the ChronoForms built-in validation.

Your form won't submit because there are form elements in the hidden block:
<div style="display: none;" id="readroot"> 
. . .
</div>
that are set as required.

The ChronoForms parser has no way to distinguish these hidden elements from the otherwise identical visible versions later in the form. They even have the same names and IDs.

There was a long thread about this many months ago and I think that one way of making it work was found but off the top of my head I don't recall what that was. I'll try and find it when I have a little more time.

Bob
This topic is locked and no more replies can be posted.