I need to count the number of items in a list, which is separated by semi-colons. I’m trying to validate that the count is not greater than a certain number onSubmit, and I’m getting a JS error that the value is null or not an object. Can someone please explain the error of my ways or offer a better suggestion on how to do this? here’s what I have:
Hidden, Number, Compute after validation field with following formula:
@If(!@IsNull(fieldList); @Elements(fieldList);0)
function:
function checkTeamMembers()
{
var f =window.document.forms[0]
if(f.field.value > 2)
{
alert("XXXX");
return false;
}
else
{
return true;
}
}
Subject: Counting elements in list - validating with JS
If this is a web application, hidden fields are not part of the document unless you use the form option “Generate HTML for all fields”, and then only in edit mode.
That being said, you’ll find that you want to check the number of entries thusly:
function checkTeamMembers() {
var valArray = document.forms[0].fieldList.value.split(“;”);