sLimit special characters and spaces
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 07:09 AM
Hi Team,
Suppose I have a single line text field on a ritm. How to limit special characters and spaces input on that so that it accepts only numbers and alphabets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 07:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 04:12 AM
This just limits special characters, not spaces
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 04:38 AM
Strange as the same is working in background script.
var pattern = /^[a-zA-Z0-9]*$/;
var testStrings = [
"HelloWorld123", // Should match
"12345", // Should match
"Test String", // Should not match (contains a space)
"Special!Char", // Should not match (contains a special character)
"Another_Test" // Should not match (contains an underscore)
];
for (var i = 0; i < testStrings.length; i++) {
var inputString = testStrings[i];
var isMatch = pattern.test(inputString);
gs.info("Input String: " + inputString + ", Matched: " + isMatch);
}
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 09:08 AM
Hi @Arka Banerjee ,
An alternative is - you can use OnChange client script on Requested Item table for the particular field which you are looking at and apply this script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Regular expression to match only numbers and alphabets
var regex = /^[A-Za-z0-9]+$/;
if (!newValue.match(regex)) {
alert("Please enter only numbers and alphabets.");
g_form.setValue(control.name, oldValue); // Reset the field value to the old value
}
}
Mark my Answer Helpful or Accept Solution if it resolves your issue.