Skip to main content
Known Participant
January 28, 2022
Answered

How to validate a field to contain xxx

  • January 28, 2022
  • 1 reply
  • 665 views

Hi all
Ive been googling but can't seem to find a simple way to do this so if you guys can help that will be awesome.

 

I'm currently making a form that contains Fields like this example

Field A = Item: Candy

Field B = Item Number: 1234

Field C = Item lot: 1234|111234

 

So I was able to use javascript so that when I enter an item name, it'll generate a corresponding item number. Now the user will have to give this item a lot number which contains the item number generated in field B. Is there a way to have the form check that Field C contains the generated number from field B?

This topic has been closed for replies.
Correct answer try67

Sure. Use this code as the field's custom Validation script:

 

var itemNumber = this.getField("Field B").valueAsString;
if (event.value && event.value.indexOf(itemNumber)==-1) {
	app.alert("You must include the Item Number.");
	event.rc = false;
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 28, 2022

Sure. Use this code as the field's custom Validation script:

 

var itemNumber = this.getField("Field B").valueAsString;
if (event.value && event.value.indexOf(itemNumber)==-1) {
	app.alert("You must include the Item Number.");
	event.rc = false;
}
Linh5FC5Author
Known Participant
January 31, 2022

It worked! Thank you!