Copy link to clipboard
Copied
I have a form that is filled out by users to set up their web accounts.
There is a section on the form that asks for their preferred username. The username must be between 8-18 characters, contain one number and cannot contain special characters.
For the 8-18 characters requirement, I put an 18 character limit under the Options tab and also entered the below Format Script:
var minLength = 8; // the minimum number of digits the user should enter
var maxLength = 18; // the maximum number of digits the user should enter
event.rc = true;
if (event.value && (event.value.length<minLength || event.value.length>maxLength)) {
app.alert("Please enter between " + minLength + " and " + maxLength + " characters.");
event.rc = false;
}
To prevent special characters from being entered, I entered the below Keystroke Script:
event.change = event.change.replace(/[^0-9a-zA-Z]/gim,"") ;
I am wondering if anyone has any suggestions on what Format/Validation Script I can use to give an error message if the username doesn't contain a number?
Copy link to clipboard
Copied
As the custom validation script enter this:
if (event.value && /\d/.test(event.value)==false) {
app.alert("You must enter at least one number.");
event.rc = false;
}
Copy link to clipboard
Copied
Thank you so much!