I have two people fields on my form that should not equal the same. If they do, the form should either not let you save or the user should receive a validation error. The requirement is that you should not be able to choose the "creator" of the form in another person text field. I cannot figure how to do this.
I was able to get validation in the form however, it is causing a validation error no matter if the fields are different or the same.
Here is the code I used:
fd.rendered(function() {
fd.field('ApprovingMgrSupvr').addValidator({
name: 'Different Approver',
error: 'The Approving Manager and form Submitter must be different',
validate: function(value) {
if (fd.field('ApprovingMgrSupvr').value !== fd.field('LoggedIn').value) {
return false;
}
return true;
}
});
});
fd.spRendered(function() {
fd.field('ApprovingMgrSupvr').addValidator({
name: 'Different Approver',
error: 'The Approving Manager and form Submitter must be different',
validate: function(value) {
if (fd.field('ApprovingMgrSupvr').value == fd.field('LoggedIn').value) {
return false;
}
return true;
}
});
fd.field('LoggedIn').addValidator({
name: 'Different LoggedIn',
error: 'The Approving Manager and form Submitter must be different',
validate: function(value) {
if (fd.field('ApprovingMgrSupvr').value == fd.field('LoggedIn').value) {
return false;
}
return true;
}
});
});
It's important to use fd.spRendered() and not fd.rendered() in this case, you also want validation on both fields, and the condition must return false when it's not what you want it to be.