I've managed to get an example up for you to look at now, it's at
http://cms.merus.co.uk/editsurvey.php.html and the javascript for the
editor is at http://cms.merus.co.uk/surveybuilder.js

At the moment only Question attempts to attach rules to fields, when a
new question is added its Label field gets a {required: true} rule
added.  This doesn't seem to work, however. The call executes without
any errors being thrown, but the validator doesn't seem to acknowledge
the rule. The rule is being added at line 349 of the javascript
file.

On Aug 16, 2:19 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Well, a testpage would help debugging it a lot.
>
> Jörn
>
> On Fri, Aug 15, 2008 at 11:03 PM, Gordon <[EMAIL PROTECTED]> wrote:
>
> > That's kinda odd, I do do the validate() on the form on document
> > ready, and I'm getting no javascript errors of any kind.  The rule
> > being added just isn't executing (just a simple required:true for now
> > while I test it).
>
> > On Aug 15, 5:37 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
> > wrote:
> >> There must be a specific error in your code, as adding new inputs to a
> >> form is generally supported, without any further hazzle that what you
> >> have in your example. Its important that the form where you add the
> >> element has the validation code initialized, but thats about it.
>
> >> Jörn
>
> >> On Fri, Aug 15, 2008 at 5:42 PM, Gordon <[EMAIL PROTECTED]> wrote:
>
> >> > I have a form in a project that allows users to build up surveys.  The
> >> > form can have controls added dynamically as users add questions to
> >> > their form.  I need to be able to validate this form client side as
> >> > sending a form to the server that it can't validate just results in an
> >> > error message and the form being lost (The server side validation is
> >> > fine, but how to handle an invalid form server side will need to be
> >> > made friendlier) so I want to avoid sending such forms if I can avoid
> >> > it.
>
> >> > What I basically need is a way of adding validation rules along with
> >> > controls so no matter the configuration of the form when it's
> >> > submitted the validator can check that it's well formed before sending
> >> > it to the server side script.
>
> >> > I was hoping setting validation up on the form on load and then using
> >> > rules ('add') on each control as I add it would work but it apparently
> >> > doesn't
>
> >> > For example, after an "Add input" button is clicked, code like below
> >> > (heavily simplified for clarity) would be executed:
>
> >> > var newControl = $('<input type="text" name="(unique name generated
> >> > earlier on goes here)" />')
> >> > surveyForm.append (newControl);
> >> > newControl.rules ('add', {'require': true});
>
> >> > This doesn't seem to cause any javascript errors, but hitting the
> >> > submit button doesn't cause the newly added control to be validated.
>
> >> > Is there something I need to do other than add a rule?  Or can't this
> >> > be done yet?  I seem to remember the above approach worked in 1.3.1
> >> > but the other problems with that version means I can't use it with my
> >> > project.

Reply via email to