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

Text field must begin with a numerical value

New Here ,
Oct 31, 2024 Oct 31, 2024

Hello Community!  

I hope someone can please help me with this problem.  I have searched for an answer to this all afternoon.

I need to create a text field that requires the user to begin their entry with digits and then any combination of letters and numbers. The number of characters in the field will vary but it must begin with 4 or 5 digits. These are some examples of how the entries would look:

  • 61220.1CS.1047849
  • 53456.1.1122714
  • 42406.FY22.1.5001141
  • 81100.000001.001.221.220700.01

I've seen a lot about the custom validation script in the field properties and regex, but I can't figure it out.

Please help! I don't know where to begin.

 

TOPICS
How to , JavaScript , PDF forms
506
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 ,
Oct 31, 2024 Oct 31, 2024

You can use this code as the field's custom Validation script (I assume there needs to be a period after the digits. If not, then you need to clarify whether it's four or five digits that the user must enter):

 

if (event.value) {
	if (/^\d{4,5}\./.test(event.value)==false) {
		app.alert("Invalid value.");
		event.rc = false;
	}
}

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 ,
Oct 31, 2024 Oct 31, 2024

You can use this code as the field's custom Validation script (I assume there needs to be a period after the digits. If not, then you need to clarify whether it's four or five digits that the user must enter):

 

if (event.value) {
	if (/^\d{4,5}\./.test(event.value)==false) {
		app.alert("Invalid value.");
		event.rc = false;
	}
}
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
New Here ,
Nov 04, 2024 Nov 04, 2024
LATEST

Thank you so much! Yes, the periods do need to be included so It works perfectly!

Thank you

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