restrict user response length to 40
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-09-2024 03:22 AM
Hi
Can we restrict user to enter more than 40 characters to a prompt pop up ?
That pop up show up when user clicks on a button on the form and enter input there, but we want user should not able enter more than 40 characters to the pop up.
How to do that?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-09-2024 05:14 AM
Is this sample code helpful?
(function executeRule(current, previous /*null when async*/) {
// Get the field element from the pop-up
var inputField = g_form.getControl('your_input_field_name'); // Replace with your field name
// Add an event listener to the input field to restrict characters
inputField.addEventListener('input', function(e) {
var maxLength = 40;
if (e.target.value.length > maxLength) {
e.target.value = e.target.value.substring(0, maxLength);
// Optionally, display a message to the user
alert('You cannot enter more than 40 characters.');
}
});
})(current, previous);