Skip to main content
Participating Frequently
December 9, 2019
Question

Create message for required fields

  • December 9, 2019
  • 2 replies
  • 689 views

Hello,

I have several fields on a form that are required. Instead of displaying a generic message stating that a required field has been left blank, I would like to display a specific message for each required field, if left blank. Below if what I was trying to start off with but I get a syntax error stating "missing; Before Statement 1: at line 2

 

Var CoreBankName = this.getField("282_Core_Ref_Bank_Name");
if (CoreBankName !== null)
{
CoreBankName.setFocus()
app.alert("Core Client Bank Name is required")
};

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
December 9, 2019

Your code is not checking if the field's value is empty, but if the field itself exists.

Also, the required property doesn't check if a field is blank, but if it has a value that's not the same as its default value.

ls_rbls
Community Expert
Community Expert
December 9, 2019

Ok I got lost with your reply a little bit.

 

Can you re-explain please what does the "if it's null" is implying in the code above?

try67
Community Expert
Community Expert
December 9, 2019

If no field exists with the name parameter you pass to getField it will return null. If it does exist it will return a Field object.

ls_rbls
Community Expert
Community Expert
December 9, 2019

NODIFIED REPLIED , I MADE AN ERROR SEE BELOW AGAIN

 

If you copy and pasted your code here, it looks like the problem is because the semicolon is outside the instruction line; it should be inside  of the curley braces.

 

See your line 2 here:

 

if (CoreBankName !== null)
{
CoreBankName.setFocus()
app.alert("Core Client Bank Name is required")
};

 

 

 

Specifically this part of line 2 : 

 

 app.alert("Core Client Bank Name is required")
};

 

 

 

It should read like this:

 

app.alert("Core Client Bank Name is required");
}