Portal Form

Certified Lead Developer
Hi All,

I have worked with Tempo forms, i need edit a portal form to add a validation on number of characters in a field.
I was able to achive giving a message saying you have crossed the allowed limit, but i want to add by how much they have exceeded.
For ex:-If character limit is 20 if user enters 25 character i want you show a message you have exceeded the limit by 5 characters.
I couldn't get the entered value in validation message as window api doesn't work nor it is saving into the activity class parameter used to save in the form.
Appreciate your help.

OriginalPostID-231190

  Discussion posts and replies are publicly visible

  • Since I haven't dealt with portal forms, I'm not sure how implementing the logic makes it difficult, but maybe you could have something like this?

    if(
    len(local!test) > 20,
    "You have exceeded the limit by " & len(local!test) - 20 & " characters.",
    {}
    )

    I hope this helps, but if not, give me your information or possibly snapshots of your interface.
  • 0
    Certified Lead Developer
    In portal forms, i have not seen any local varibles declared.
    The tricky part is we can get the value using window.FormAPI.getValue("text89").id in the validation check but not in the validation message.
  • For portal forms you are pretty much stuck with JavaScript for validations -- below is one function I have used for limiting length in text fields.
    /* After each character is typed the text length is checked. When the maximum text limit
    is exceeded an alert pops up to notify the user and any extra characters are truncated.
    The function will also works for text that is pasted into the field. The same function
    can be used for any or all of the text fields on a form, with the exception of rich text fields.*/
    // Usage: textLimit("simpleParagraph", 500); [attached to keyup Event]
    function textLimit(field, maxLimit) {
    var textareaValue = window.FormAPI.getValue(field).id;
    if (textareaValue.length > maxLimit) { // if too long trim the field
    textareaValue = textareaValue.substring(0, maxLimit);
    var msg = "You have reached the maximum number of characters (" + maxLimit + ") allowed in this field.";
    asi.alert(msg); // pop up a message to alert user
    window.FormAPI.setValue(field, textareaValue);
    }
    }
  • Oh cool this is good to know. Thanks for giving this feedback Robins