Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
linenumberstrue
import java.util.Arrays;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.service.FormUtil;
    
if(values[0].length() > 500){
    String id = FormUtil.getElementParameterName(element);
    formData.addFormError(id, "Value cannot be longer than 500 characters. You have entered " + values[0].length() + " characters.");
    return false;
}else{
    return true;
}

Field value does not exceed 500 in numerical value

Code Block
languagejava
linenumberstrue
import java.util.Arrays;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.service.FormUtil;

String id = FormUtil.getElementParameterName(element);
String amount = "";
if(values.length > 0){
    amount = values[0];
}

if(amount.isEmpty()){
    formData.addFormError(id, "Please key in a amount.");
    return false;
}else{
    float amountF = Float.parseFloat(amount);
    if(amountF >=500){
        formData.addFormError(id, "Amount cannot be more than 500.");
        return false;
    }
}

return true;


Use as Form Multi Row Load Binder

...