Javascript needed for required field entry before moving to next field

New Here ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

I have a form that has 2 required fields.  The person needs to enter a zero or some other amount before tabbing or clicking into the next field.  If they do not enter an amount, I'd like a message box to pop up requiring them to enter an amount.  Is there a script that I can use to make this happen?  I've searched the questions but am a complete newcomer to javascript so I need assistance.  Thanks.  

TOPICS
JavaScript, PDF forms

Views

200

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Apr 15, 2021 Apr 15, 2021
Check 'field calculation order', in 'prepare form' click on 'more'-> 'set field calculation order' and make sure on top is field that calculates first, it should look something like this: field3 field4 field7 field8 field9 If that doesn't help, upload your file here so we can take a look.

Likes

Translate

Translate
Adobe Employee ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hi there

 

Hope you are doing ewll and sorry for the toruble. As described you need JavaScript to enter a zero or some other amount before tabbing or clicking into the next field.

 

Please check out the help article https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_developer_guide.pdf and see if that works for your.

 

Hope it will help

 

Regards

Amal

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

You're asking for different things, not just one script.

 

For example, I would begin by leaving the first input field fillable, and the second field readonly.

 

Then you may employ a custom keystroke script in the first required target field with a conditional statement to handle the part that the value is equal, greater or lesser than 0.  

 

You may also want to add a condition to make the second field editable again if the values of the first field meet the criteria indicated by the script.

 

Employing the use of an alert is not necessarily required to remind the user that they missed to fill in the first field if you do it like this.

 

But yes you may add an alert to remind them just in case they move to other parts of the form without entering a value in the first field.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

How are you sure they will click in first field? and why would they click in first field and then tab out to next field whitout filling it first?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

It's a very bad user experience to be "locked" into a field like that. I would recommend you use some other way of making sure they enter a value into that field.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Maybe I don't need to make it a 'requirement' for the user.  Here's the issue:  I have fields that calculate from input.  For whatever reason, if nothing is in a field that is part of a calculation, the calculation does not work 100%.  For example, users enter numbers into field 1, field 2 is 'optional' as it may or  may not apply to them, and field 3 calculates the difference between the 2 fields.  Field 3 calculates correctly. Field 4 uses the number in field 3 and multiplies it by a percentage.  This works correctly.  However, field 4 is used in another calculated field, field 8, further down the page.  Field 8 adds field 4 and field 7.  Field 8 will not add field 4 to it unless a zero is filled into fields 2 and field 6.  I've tried putting a default value of '0', but it doesn't seem to make a difference.  See below:  line 9 should be adding lines 4 & 8, and it is set up to do this in properties, but it doesn't calculate unless something is entered in lines 2 and 6.  ????  I'm sure I'm doing something wrong.  This is the first time I've worked with adobe acrobat forms so I'm learning as I go.  Thanks for your input and help.

 

defaultuob5m0kayu27_0-1618485198053.pngdefaultuob5m0kayu27_1-1618485226798.png

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Check 'field calculation order', in 'prepare form' click on 'more'-> 'set field calculation order' and make sure on top is field that calculates first, it should look something like this:

field3

field4

field7

field8

field9

If that doesn't help, upload your file here so we can take a look.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

LATEST

Thank you!  That fixed my problem!  I missed the 'more' option and frankly didn't know it was there.  I'm glad I didn't need to go the route of required fields etc.  Thanks again!  Truly appreciate your assistance!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines