I have created three email textfield in joget. I want the emails to be unique for every email field.
The screenshort is attached. I want to display error if the email id of either of them are same !!
How can i do that?
`import java.util.Arrays;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.Form;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.service.FormUtil;
public boolean validate(Element element, FormData formData, String[] values) {
boolean result = true;
//get field 1 value from form data object
String field1Id = "field1";
Form form = FormUtil.findRootForm(element);
Element field1 = FormUtil.findElement(field1Id, form, formData);
if (field1 != null) {
//get value of field 1
String[] compareValues = FormUtil.getElementPropertyValues(field1, formData);
//compare the value of field 2 and field 1 are equals
if (!Arrays.equals(values, compareValues)) {
String id = FormUtil.getElementParameterName(element);
formData.addFormError(id, "Value not equal!!!!");
result = false;
}
} else {
//ignore if the field 1 not exist
}
return result;
}
//call validate method with injected variable
return validate(element, formData, values);`
I had written this code but wasn't successfully. I would really help me if you can help me with J query code / JS code. AS joget supports it