We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

restrict user response length to 40

Not applicable

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

HIROSHI SATOH
Mega Sage

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);