Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Text field validation with a Twist

Avatar

Not applicable
I have three text fields texta, textb and textc in which they need to validated upon submitting the document via a submit button. I need to validate the following:



When the user enters information into TextfieldA then TextfieldB and C dont need to be validated but if a user enters information into TextfieldB then TextfieldA and C dont need to be validated and so fourth. All three Text fields still need to be validated if the user has entered any information into any of them.



How would I go about solving this problem on the submit button or any other way?



Thanks
3 Replies

Avatar

Not applicable
Since it sounds like you only need to perform the validations just before the form gets submitted, you can probably use what I call the "two button submit technique" (I'm going with a term here since it's used so often).



This consists of using two buttons: One regular button and one submit button (either email or HTTP). The submit button is made invisible and the Click event of the regular button (the "fake submit button") is used to perform the validations and, if all succeed, execute the invisible submit button's Click event, triggering the submission of the form.



To illustrate this concept, I've created a sample form with three text fields where at least one text field needs to be filled prior to submitting the form.



Stefan

Adobe Systems

Avatar

Not applicable
FormBuilder@adobeforums.com wrote:

> Since it sounds like you only need to perform the validations just before the form gets submitted, you can probably use what I call the "two button submit technique" (I'm going with a term here since it's used so often).

>

> This consists of using two buttons: One regular button and one submit button (either email or HTTP). The submit button is made invisible and the Click event of the regular button (the "fake submit button") is used to perform the validations and, if all succeed, execute the invisible submit button's Click event, triggering the submission of the form.

>

> To illustrate this concept, I've created a sample form with three text fields where at least one text field needs to be filled prior to submitting the form.

>

> Stefan

> Adobe Systems



You can also manipulate the 'mandatory' property in script. For example, you could set all three

fields to required initially, and then you could put the following code on the 'exit' event of field A:

if (this.rawValue != null)

{

this.mandatory = "error";

this.parent.fieldB.mandatory = "disabled";

this.parent.fieldC.mandatory = "disabled";

}



This will make fieldB and fieldC optional once fieldA has been filled in. You would put similar

script on the other two fields.



The benefit of this over the two-button submit technique is that you will still get the automatic

validation and highlighting of required fields that is provided within Acrobat and Reader.



--

Justin Klei

Cardinal Solutions Group

www.cardinalsolutions.com

Avatar

Not applicable
Thanks Stefan Your a Asset to Adobe Systems.



Thank you from the land downunder (Australia)