Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with implementing restrictions to required numeric fields on a form

Explorer ,
May 05, 2019 May 05, 2019

Hi,

I need some help with putting restrictions on two fields - a policy # and a loan #. They'll both be numeric only in any variety of combination, policy # containing only 13 digits, while the loan # has no limit. I want both fields to allow only numeric characters, and prompt a warning message if they're not filled out correctly. I attempted some script to do this but it didn't go well Any help is greatly appreciated!

Thanks,

Valerie

TOPICS
PDF forms
2.1K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
May 12, 2019 May 12, 2019

Are you entering a 13-digit value? If so, it should work.

And no, I didn't add an error message, but that can be easily done, by adding this line to the end of the validation script:

if (!event.rc) app.alert("Error! You must enter a 13-digit number.");

View solution in original post

Translate
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
Community Expert ,
May 05, 2019 May 05, 2019

Do you want to limit what the user can enter, or to validate the value when they exit the field, and only allow it if it adheres to these rules?

Translate
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
Explorer ,
May 05, 2019 May 05, 2019

I want to limit each field to numeric characters, with the policy# only allowing 13 digits, no more no less. Because both the policy and loan number can be any combination of numbers, I don't know how we could introduce validation, but then again i only know the very basics of creating forms; these validating things are not my cup of tea. The loan number shouldn't be limited to any certain number of characters. Thanks!

Translate
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
Community Expert ,
May 05, 2019 May 05, 2019

OK, then go to the Properties of both fields, and enter the following code under Format - Custom - Custom Keystroke script.

event.rc = /^\d*$/.test(AFMergeChange(event));

It's possible that after you enter this code it will disappear. That's OK. Just click Close and it should work.

For the Policy # field go to Options tab and set the character limit to 13.

Translate
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
Explorer ,
May 07, 2019 May 07, 2019

Yes, this worked!! Thanks so much!

V

Translate
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
Explorer ,
May 11, 2019 May 11, 2019

Hi,

It seems I am actually having a bit of trouble with this still as the Policy # will allow me to put in only numerical values (great!) but less than 13 characters (not great). I did try both a limit of 13 and a comb of 13 for the field and neither worked. Would you be able to help me figure out this part to please?

Thanks!

Translate
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
Community Expert ,
May 11, 2019 May 11, 2019

Ah, so the value must only be exactly 13 digits? Then use this code:

if (event.value) event.rc = /^\d{13}$/.test(AFMergeChange(event));

Translate
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
Explorer ,
May 11, 2019 May 11, 2019

Hi, yeah, 13 and only 13, sorry about that. And I'm not sure what I'm doing wrong, but I put that in a custom keystroke script, a custom format script, took out the comb of characters, put it back in, etc. and couldn't make it work with what I need. When it's in the keystroke, I'm only able to put in 1 number, when it's in format, I can type in infinity. Not sure what I'm doing wrong... Thanks for continuing to help me! It's just without validating or confirming that an entry of exactly 13 numbers has been inputted, the form isn't really helpful to the dept. I'm doing it for.

Translate
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
Community Expert ,
May 11, 2019 May 11, 2019

My bad, use this code as the custom validation script:

if (event.value) event.rc = /^\d{13}$/.test(event.value);

And go back to the previous version of the Keystroke code, with the limit set to 13.

Translate
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
Explorer ,
May 11, 2019 May 11, 2019

Hmm. So it's set a character of limit of 13 (yay), no alpha (yay again), but when I press tab to proceed to the next field, the numbers I entered are removed, and then to move onto another field I must press tab again. No alert pops up about 13 digits, and the numbers just disappear. I must be doing something wrong? I did the prior custom keystroke script, limit of 13, and added your new validation script...

Translate
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
Community Expert ,
May 12, 2019 May 12, 2019

Are you entering a 13-digit value? If so, it should work.

And no, I didn't add an error message, but that can be easily done, by adding this line to the end of the validation script:

if (!event.rc) app.alert("Error! You must enter a 13-digit number.");

Translate
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
Explorer ,
May 13, 2019 May 13, 2019
LATEST

Thank you so much!!! Not sure exactly what the problem was Saturday, but this is working correctly and the warning pops ups when less than 13 digits are entered. I really appreciate all your help!

V

Translate
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