Hello! We are using the Plumsail Public Forms and are trying to find a way to limit the number of characters in a multi-line text box to 3,000 characters. Has anyone done this? I know the attribute for HTML inputs, but I am not sure how that would be used in the designer.
Dear @kkreitzer,
Sure, we can help, but we might need a little more details to make it work with your situations specifically:
Do you want users to be able to input more than 3,000 characters, but then not being able to save the form, like validation? Or do you want some hard limit, when users are not even able to type in more than 3,000 characters?
Is this Multiline Field Plain Text or Rich Text? The value returned would be different, and if it’s Rich Text, there needs to be additional code to remove all the styling from the value.
Finally, do you want to include spaces as characters, or should only actual visible characters count?
In case you have a simple Plain Text Multiline Field, you can use the following code for validation, though it will include spaces as well:
fd.spRendered(function() {
fd.validators.push({
name: 'FieldLengthValidator',
error: "FIELD_NAME must be not longer than 3000 characters",
validate: function() {
if (fd.field('FIELD_NAME').value.length <= 3000) {
return true;
}
return false;
}
});
});
Hi Nikita.
I've tried this exact code on a public form, changing the value to 600. However it doesn't prevent long submissions. Is there more code that I need in JS than this?
Below is exactly what I've entered. 'Instructions' is the internal name of the field.
fd.spRendered(function() {
fd.validators.push({
name: 'FieldLengthValidator',
error: "Instructions must be not longer than 600 characters",
validate: function() {
if (fd.field('Instructions').value.length <= 600) {
return true;
}
return false;
}
});
});
Hi, I need the solution for entering hard limits where the users will not be able to type in more than the character limit of 3,000. These limit should include spaces and punctuation. I need this for both Plain and Rich multiline text boxes.
I also have some situations where the limit is based on words, for example 200 word limit in multiline text boxes. Is that possible to have as hard limits as well.
To hard limit the number of characters in the Plain text field, you can use this code:
text = fd.field('FIELD_NAME').value;
function limitCharacters(fieldName){
var newText = fd.field(fieldName).value;
if(fd.field(fieldName).value.length > 3000) {
fd.field(fieldName).value = text;
}
else {
text = newText;
}
}
fd.field('FIELD_NAME').$on('change', function(value) {
limitCharacters('FIELD_NAME');
});
If you need help with limiting the number of character in the Rich text field and setting the limit on word number, we can offer you a paid support. Please contact us via support@plumsail.com
Total newbie here with no formal training in coding...apologies for the likely incredibly simplistic questions...I'm using the Plumsail online form builder to make a public form that will use a process to auto-populate data into a PowerPoint template. I need to limit the number of characters as described above on multiple 'single line text' and 'Multiline text' (simple text) inputs in my form. each field may have a different max character count due to how the field input will fit into the final PPT.
My silly question is, with the code above...literally...where do I put it in the form builder? Is it in the 'style' of each single line text element? Or in the JavaScript Editor for the complete form? Or somewhere completely different?
1.) I am trying to get my single line of text to only allow numbers(numeric) and no alphabetical text. At the moment I cannot find any way of doing this?
2.) How can I make sure that when my field is limited to only allow 8 characters, that it will insert a leading 00 if there is only 6 characters typed in?