
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 03:53 AM
Hi,
I have a variable Description. The requirement is to NOT allow for any UPPERCASE letters. Auto adjust to all lowercase please. Also the requirement is to not allow more than 18 characters. 18 characters part is done though. Kindly help.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var contains_space = "";
var more_chars = "";
var regex = new RegExp("^[a-zA-Z0-9]*$");
if (newValue.length > 18) {
alert("More than 18 chacters entered.");
g_form.setValue('description', " ");
} else if (!regex.test(newValue)) {
var no_space = newValue.replace(" ", "_");
g_form.setValue('description', no_space);
// g_form.setValue('topic', no_space);
contains_space = "true";
}
}
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 04:07 AM
Hi @Community Alums
If you want to convert all characters to lower case automatically, try the following script in your onChange.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var contains_space = "";
var more_chars = "";
var regex = new RegExp("^[a-zA-Z0-9]*$");
if (newValue.length > 18) {
alert("More than 18 chacters entered.");
g_form.setValue('description', " ");
} else if (!regex.test(newValue)) {
var no_space = newValue.replaceAll(" ", "_");
g_form.setValue('description', no_space.toLowerCase());
// g_form.setValue('topic', no_space);
contains_space = "true";
} else {
g_form.setValue('description', newValue.toLowerCase());
}
}
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 04:07 AM
Hi @Community Alums
If you want to convert all characters to lower case automatically, try the following script in your onChange.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var contains_space = "";
var more_chars = "";
var regex = new RegExp("^[a-zA-Z0-9]*$");
if (newValue.length > 18) {
alert("More than 18 chacters entered.");
g_form.setValue('description', " ");
} else if (!regex.test(newValue)) {
var no_space = newValue.replaceAll(" ", "_");
g_form.setValue('description', no_space.toLowerCase());
// g_form.setValue('topic', no_space);
contains_space = "true";
} else {
g_form.setValue('description', newValue.toLowerCase());
}
}
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:10 AM
Hi Anvesh, can we add multiple variables in one on change to restrict to convert to lower case