Skip to Content
0
Feb 27 at 09:50 AM

SAP MDK SimpleProperty only digits allowed

426 Views

Hello experts

I need for my SimpleProperty a rule to allow just digits. I was trying in different ways but it's not working properly.

export default function validateNumbersOnly() { var control = page.getControl('CurrencyCode');
control.onValueChange(function(event) { var value = event.newValue;
if (!/^\d*$/.test(value)) { event.preventDefault(); control.setError('Please enter only digits.'); } else { control.clearError(); } });}or like this
evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;