Here is a function that validates input by checking for numbers and no spaces in between:
checkInputValidity: function() {
var isValid = true;
var idNumber = this.getView().byId("iDNumber");
var regex = /^[0-9]+$/;
if (idNumber.getValue().trim().length === 0 || (idNumber.getValue().match(regex) == null)) {
isValid = false;
idNumber.setValueState(sap.ui.core.ValueState.Error);
} else {
idNumber.setValueState(sap.ui.core.ValueState.Success);
}
return isValid;
}
I am facing an issue where Chrome ignores white spaces in the input field even though it should only accept numeric values without spaces. On the other hand, Internet Explorer accepts spaces which results in inconsistent behavior. How can I make the behavior consistent across browsers?