Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How do I make field mandatory?

Avatar

Former Community Member
First and foremost, forgive me for my inexperience.



I am attempting to create a form with mandatory fields. I have tried switching the value type to user-required, but this does not yield the results I was hoping for. I would like the user to be unable to proceed beyond the mandatory field if they do not enter the required data. How do I make this happen?



Thanks in advance for your time and response.
4 Replies

Avatar

Former Community Member
Allo,



This type of control may cause bad user experience. The end-user may want to fill other parts of the form and come back to the required fields later. Why prevent him/her from doing that?



If you let the end-user browse the form freely, the submit process will warn the end-user when s/he attempts to submit the form with empty required fields. In other words, the user wont be able to submit this form until all required fields are filled.



Now, you may have good reasons to enforce this behavior. In this case, you can write a JavaScript on the exit event of the required field.



if (this.rawValue == null)

xfa.host.setFocus(this);



Hope this helps.



Cheers,



Hélène

Adobe Systems

Avatar

Level 9
Hi Helene

Please note that your setFocus method won't work. setFocus needs a string expression, not an object.

Try xfa.host.setFocus(this.somExpression);



If you bump into anyone over the water cooler who can help, this is a common problem, and it doesn't seem to be too hard to tweak setFocus to allow objects ;-)



Howard

http://www.avoka.com

Avatar

Former Community Member
Hi Howard,



Thats true for older versions. However, starting with version 8.1, you can pass an object to the setFocus() method.



Thanks for pointing it out.



Cheers,



Hélène

Adobe Systems

Avatar

Level 9
Hi Helene

That's cool, always nice when a feature gets added before you ask for it :-)



LaVerna, please be aware that while Helene's code will work in Reader 8, if you're designing forms that also work on Reader 7, you will have to use my variation of the script.



Howard

http://www.avoka.com