Hi,
I need to add wordcount validation for specific fields in Opportunity entity on an advanced web form. Does anybody know how to do this?
It needs to display a customisable alert and work for both typed and pasted words on clicking continue to next web form step.
Help!!
James
Hi Jim,
Glad to know our solution worked for you. If you dont mind, can you please mark my answer as verified so that if someone else also face similar issue in future, they can try the same since they would prefer the solution if its a verified one.
Thanks,
Thank you very much! That is very helpful. Literal gold star moment
We can use java script to achieve wordcount validation for specific field on Opportunity Advanced Form.
• Step 1 : Add below code to the Advanced Form Step form under Form options tab. And save it.
$(document).ready(function () {
//Create word count validator
var wordCountValidator = document.createElement('span');
//setup validator property and associated field
wordCountValidator.style.display = "none";
wordCountValidator.id = "new_wordcount_Validator";
wordCountValidator.controltovalidate = "name"; // single of text
wordCountValidator.evaluationfunction = function () {
var wordCount= $("#name").val();
var countWords = (wordCount.split(" ")).length;
if (wordCount!== null && wordCount!== "" && wordCount!== undefined) { // Check condition
if (countWords > 2) { // check sub condition
//setup custom validation message
this.errormessage = "<a href='#new_wordcount_label'>Topic should be of two words.</a>";
return false;
}
else {
return true;
}
}
else {
return true;
}
};
// Add the validator to the page validators array:
Page_Validators.push(wordCountValidator);
});
• Step 2 : Clear portal cache and view the result.
If entered topic value is more the two then it will show the error message
• Step 3 : If entered topic value is two or less than two it will save the form.
• After clicking on submit button it will save form
• It works for both typed and pasted words.
Hope this helps!!!
If you find this solution helpful, please mark it as verified.
Siv Sagar
149
Super User 2025 Season 1
Muhammad Shahzad Sh...
61
Most Valuable Professional
Daivat Vartak (v-9d...
53
Super User 2025 Season 1