Validate numeric values only.
I have a form that requires only the last 4 digits of a social. I am using a custom validation script to check for 4 values in length:
event.rc = true;
if (event.value.length == 4){
event.target.textColor = color.black; }
else {
app.alert("The entered value needs to be 4 characters long.");
event.target.textColor = color.red; }
The customer has requested to allow a dash character "-" before the numbers and still validate that 4 numbers have been added. This is in case the user wants to add a "-" before the numbers. I removed the format for numbers and set the limit to 5 characters, but now it validates the "-" before the numbers as the length and if 3 numbers are entered it renders true which is wrong. Example, -123.
Is there a way to only count the numbers entered and nothing else?
