I have a variable called business justification, it is having the validation to enter minimum 50 cha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 08:39 AM
I have a variable called business justification, it is having the validation to enter minimum 50 characters, it was done by using client script .
How to show the how many characters were typed already in the field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 08:50 AM
How are you trying to show it? The below script would log the length of the variable to the browser console.
var justification = g_form.getValue("variable_name");
console.log(justification.length); // prints the number of characters in the variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 08:58 AM
Hi @Archana23
If you just want to display once the text is entered, you can use the same client script with field message. If you want to display the number of characters typed as you type (like you see while composing an SMS in mobile) you need to use DOM Manipulation, which is not recommended.
For the first scenarion, try this in onChange client script and onSubmit client script.
onChange client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue.length < 50){
g_form.showFieldMsg('business_justification', 'Business justification should be at least 50 characters. Now you have entered only ' + newValue.length + ' characters.', 'error');
}
}
onSubmit Client Script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var business_justification = g_form.getValue('business_justification');
if(business_justification.length < 50){
g_form.showFieldMsg('business_justification', 'Business justification should be at least 50 characters. Now you have entered only ' + newValue.length + ' characters.', 'error');
return false;
}
}
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
08-02-2024 09:04 AM
@Archana23 You can create an onChange script and count the number of characters in it and show the count as field message.