Home > Forum > Rules, JS, SQL > Feature request: Set field error text within a form rule / javascript

Feature request: Set field error text within a form rule / javascript
0

Hello,

I personally like immediate validation – right after the user checks/selects/enters something on the form - much better than validation on an action.

So usually I validate fields “on value change” and set the field error if necessary.

Currently I use a js-function like this to showing/remove the error message (form display mode: Modern on BPS portal):

function showError(columnName, hintText) {
let errorLines = $("#" + columnName + " .attributeErrorsPanel li");
if (errorLines.length === 0) {
$("#" + columnName + " .attributeErrorsPanel").css("height", "auto")
$("#" + columnName + " .validation-error-panel").addClass("has-error")
$("#" + columnName + " .attributeErrorsPanel").append("<li>" + hintText + "</li>")
}
}

function removeError(columnName) {
$("#" + columnName + " .attributeErrorsPanel").css("height", "0px")
$("#" + columnName + " .validation-error-panel").removeClass("has-error")
$("#" + columnName + " .attributeErrorsPanel li").remove()
}

My javascript doesn’t work with item list.

It would be nice if we could have a built-in form rule function / JS function like SET ERROR(Field, errorText) - for every form diyplay mode .
It would also be desirable to have something like this for item lists: SET ERROR ITEM LIST (ItemList, Row, errorText)
The counterpart CLEAR ERROR would also be fine to remove the error message.

My approach is not that ideal, because I must do validation twice, once a user changes something in the form and the second time, when an action will be executed. But it is much better than validation during an action and showing the error message in a dialog.

Thank you,
Balint

Nobody has replied in this thread yet.