0

I have a form in which a user can select the type of text input field that they would like to use (based on the available text input type fields that the clientside validation model supports - let's call this textfield A). Also on that page is another textfield (B) that permits a user to enter a default answer to be display in textfield A.

The problem I am having is that when the textfield type is select (say numeric values only), I would like the textfield B implement the selected validation rule and verify that the text in that field is indeed all numeric. Likewise if I change type to email that textfield B's validation rule updates and checks that the enter text conforms to the new rule.

Currently what I have set up is that when a text input type is selected an new textfield B is created with the new validation rule and the text (if entered) from the previous textfield entered as the default answer (this is done through AJAX calls and a custom module). The problem is that when the answer is validated, it is still using the original validation rule (regardless of how many times I select a different validation rule). It almost seems like the clientside javascript never gets updated. I am wondering if anyone has experienced this before and how one would go about fixing it?

Thanks.

PS I am using Drupal 7 and clientside validation module (both latest versions).

3
  • from the project page .... what makes you think this module works with AJAX driven forms? drupal.org/project/clientside_validation You may be able to use FAPI #states to enable or disable validation rules or change them. But, I doubt it.
    – tenken
    Commented Jun 19, 2013 at 17:11
  • You bring up a good point. I assumed that the JavaScript used to validate the text field handled all variations so that it didn't matter if the validation rule changed on fly. Perhaps it doesn't work that way. If it doesn't, then I probably need to create a new validation rule that takes that into account.
    – user5013
    Commented Jun 19, 2013 at 17:37
  • you may find this helpful (and the related threads therein) drupal.org/node/1948006 i just searched custom_validation's issue queue for "ajax field" ....
    – tenken
    Commented Jun 19, 2013 at 18:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.