Validation Not Reading Push

Hello,
I am trying to input a validation for two people picker fields named
Validator
InventorySupervisors

I am using Forms. My code is this:
fd.field('Validator').validators.push({
name:'MyCustomValidator',
error: "Validation field is required",
validate: function(){
if(fd.field('Validator').value==null){
return true;
}
return false;
}
});

fd.field('InventorySupervisor').validators.push({
name: 'MyCustomValidator2',
error: "Inventory Supervisor field is required",
validate: function() {
if (fd.field('InventorySupervisor').value==null){
return true;
}
return false;
}
});

It is not working. When I look at the developer tools it says it cannot read the push. What am I doing wrong?

Hello @David_E_Garza,

What application are you using? Forms for Modern UI or Forms Designer for Classic UI?

Using forms designer for classic UI.

Hello @David_E_Garza,

Please find out how to make fields required in Forms Designer here:

In the future, it would be better to ask Forms Designer questions on the original forum, this forum is dedicated to Plumsail Forms, our newer product.

I will post on the original forum moving forward. So I assume I am using the wrong code. So now I am trying to use
fd.onsubmit(function() {
if (!fd.field('title').value()) {

	alert('Please enter a task name');
	return false;
}

return true;

});
to have my own validation error. It works when missing something however when I re enter a title it still gives me the error. What I am trying to do is have 3 fields with their own validation error. They are all required however for whatever reason using the forms only title works and not the other 2 fields. Hence I am trying to create my own validation error for these two fields which are people pickers. Do I need to somehow add an refresh after it checks the fields?

@David_E_Garza,

You need to use field internal name in the code. You can find it in the properties panel in the designer:
image

The internal name is case sensitive, thus the title field internal name is Title. Please update the code:

fd.onsubmit(function() {
if (!fd.field('Title').value()) {

	alert('Please enter a task name');
	return false;
}

return true;
});

This works for the Title field, however it does not work for my people picker field. Is this done differently? I made sure the internal name is correct, also it is a required field.

Hello Margarita,
I figured it out! For the people picker field I wrote following code:
fd.onsubmit(function() {
if (!fd.field('Validator').value().length) {

alert('Please enter a validator name');
return false;

}

return true;
});

Again, thank you for your help! Ya'll provide great customer service.

1 Like