Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.");
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Yes, this worked!! Thanks so much!
V
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Ah, so the value must only be exactly 13 digits? Then use this code:
if (event.value) event.rc = /^\d{13}$/.test(AFMergeChange(event));
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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... ![]()
Copy link to clipboard
Copied
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.");
Copy link to clipboard
Copied
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
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more