Help for validating variable, length should be 5 entries upto 255 characters

Are Kaveri
Tera Contributor

Hi All,

 

I have a requirement for which I have to create a variable and apply below validation.

For ID variable, the user has able to add upto 5 entries upto 255 characters.

I am unable to apply validation. Could anyone suggest me how to achieve above validation for a variable.

 

1 ACCEPTED SOLUTION

Try something like this 

Change length values and variables names as needed.

 

function onSubmit()


{
    var studentID = g_form.getValue('u_email');

	var arrayID = studentID.split(',');

    if (studentID.length >= 254 || arrayID.length >= 4) {

        g_form.addErrorMessage('Please ensure the Student ID is 255 characters long');
        return false;
    }
}

***Mark Correct or Helpful if it helps.***

View solution in original post

3 REPLIES 3

Yousaf
Giga Sage

Hi,

Are you talking about field on the form or variable in catalog item ? 

OOB field length for Question is 255. You need to do below.

1. Open the required variable form.

2. Right click the Question field & then Configure Dictionary

3. Then update Max length field.

 

Mark Correct or Helpful if it helps.


***Mark Correct or Helpful if it helps.***

On a record producer I have created a variable called student id and I need to apply validation for the student id variable. If user adds more than 5 entries with comma separated values he need to get alert and the whole length should not exceed 255 characters.

The max length, i have added in attribute. But I am not understanding understanding how to add validation.

Try something like this 

Change length values and variables names as needed.

 

function onSubmit()


{
    var studentID = g_form.getValue('u_email');

	var arrayID = studentID.split(',');

    if (studentID.length >= 254 || arrayID.length >= 4) {

        g_form.addErrorMessage('Please ensure the Student ID is 255 characters long');
        return false;
    }
}

***Mark Correct or Helpful if it helps.***