Form Fields with 0's/Error Messaging and Field Tabbing/Error Messaging

Participant ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Hey everyone,

 

I am trying to figure out a few things and after multiple failed attempts I thought I would post my example along with what I am trying to achieve in hopes of some assistance from the experts in the community!

 

My first challenge: Setting fields up so that if a zero or multiple zeros are entered, the field error messaging will not display like how it is in my example. It doesn't seem to recognize the 0 as an entry.

 

My second challenge: If I tab or move through fields, I have error messaging that appears (and minus the first challenge, this seems to be otherwise working). However, I am wondering if there is a way for the cursor to remain on the field in relation to the error message, versus going to the next field like it currently is.


I have attached my example which I hope helps to better explain what I am trying to do, and hopefully determine where I am going wrong.

 

Thank you in advance for any assistance 🙂

TOPICS
PDF forms

Views

70

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 2 Correct answers

Adobe Community Professional , Jul 14, 2022 Jul 14, 2022

Change your code to:

if (getField("Account Number").valueAsString=="") app.alert("Account Number is required!");

Likes

Translate

Translate
Participant , Jul 15, 2022 Jul 15, 2022

Ideally, this is what I'm hoping to achieve unless it's not possible without creating new issues. Added info in the attached as well for reference.

I would like to have the error appear if a field is tabbed without entering on it. And when the ok button is clicked, the cursor remains on that field (instead of going to the next field). You had mentioned that this would have two error messages (since it tabs to the next field). Is there a way to do this to avoid having the two error messages, so it

...

Likes

Translate

Translate
Participant ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Accidentally deleted the note I had for Policy Number but it's a number only field as well, working like account number. Regardless of whether it's a number field or a number/letter field, the issue is the same with the error message box displaying when only 0 or 0's are entered and I'm trying to solve that 🙂

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Change your code to:

if (getField("Account Number").valueAsString=="") app.alert("Account Number is required!");

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

To stay on the same field use this:

this.getField("Account Number").setFocus();
I don't recommend you do that, though. Also, if you use Tab then it will show two error messages, if the Member ID field is also empty (as it's On Blur event will execute as well). You should use the Validation script for this, actually.

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
Participant ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

So sorry, having a hard time following and making this work. It doesn't take much to confuse me. Is the answer here that having it stay on the same field after the error message is not wise? I am not sure what the Validation script is, so if there is a way to expand on this I will do my best to try and understand. Thank you!!!

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Try this code as the field's custom Validation script, instead of the On Blur one:

 

if (event.value=="") {app.alert("Account Number is required!"); event.target.setFocus();}

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
Participant ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Thanks @try67 I appreciate the response. I have attempted this, but I think I'm still not following instruction well enough. Now, I seem to get error messages only when I click the Clear Form button, so I'm assuming I have boggled things up.

 

I did remove the On Blur (which did work for making the 0's appear without throwing an error:
if (getField("Account Number").valueAsString=="") app.alert("Account Number is required!");),

 

and added the code to the custom validation script (in the attached example).
if (event.value=="") {app.alert("Account Number is required!"); event.target.setFocus();}

 

Thank you again.

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

I'm not getting any errors when I click the Clear Form button.

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
Participant ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

So now I don't get any error if I tab through without entering anything in the fields.

If I enter text on the fields, and then click Clear, it throws the error messages. If you try clearing this attached example that has field entries, does it happen for you now? Thanks

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Yes, that does happen. I guess we need to take a step back. When exactly do you want this message to appear?

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
Participant ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Ideally, this is what I'm hoping to achieve unless it's not possible without creating new issues. Added info in the attached as well for reference.

I would like to have the error appear if a field is tabbed without entering on it. And when the ok button is clicked, the cursor remains on that field (instead of going to the next field). You had mentioned that this would have two error messages (since it tabs to the next field). Is there a way to do this to avoid having the two error messages, so it remains on the field related to the error message? If I cannot do this, it is fine, I just wasn't sure I was understanding earlier direection and was hoping to clarify. Thanks again!

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Then you will need to use the On Blur event, and I don't see a way to avoid having the two error messages, sorry.

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
Participant ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

LATEST

Thanks @try67 I appreciate the reply!

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