cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

Limit text field characters based on choice field

Hi

 

I am looking to limit characters in a text field based on a choice field selection.

 

I have 4 choices in th echoice field each require a specific amount of characters entered in the text field.

 

E.G

 

If choice Choice 1 is selected the text box can only contain 14 characters 

If choice Choice 2 is selected the text box can only contain 11 characters

If choice Choice 3 is selected the text box can only contain 8 characters

If choice Choice 4 is selected the text box can only contain 8 characters  

Labels: (1)
Reply
4 Replies
Highlighted
Nintex Newbie

Re: Limit text field characters based on choice field

 using classic forms, javascipt code can be used to do the following

- place an eventlistener 'keydown' on the input controls

- in the function check for dropdown list selection

- check for char length of input at time

- depending on dropdown selection and current length allow input or not

- display a alert to the user of some sort

Reply
Highlighted
Nintex Employee
Nintex Employee

Re: Limit text field characters based on choice field

Use a validation rule.
and(equals(ChoiceControl,"Option 1"),!equals(length(toLower(textControl)),14)) || and(equals(ChoiceControl,"Option 2"),!equals(length(toLower(textControl)),11)) || and(equals(ChoiceControl,"Option 3"),!equals(length(toLower(textControl)),8)) || and(equals(ChoiceControl,"Option 4"),!equals(length(toLower(textControl)),8))

No javascript required and it will work with Classic or Responsive forms.
Reply
Highlighted
Nintex Newbie

Re: Limit text field characters based on choice field

 Nice! I often start with rules, get get lost in a sea of brackets and nothing working and give up :smileylol::cathappy: - I'll have to give it another go 

Reply
Highlighted
Nintex Newbie

Re: Limit text field characters based on choice field

Thanks for the help guys. I made this work through Validation settings and column validation on SharePoint.

 

Within Validation settings I ran the below:

=IF(Entity="Choice 1",LEN([Textbox])=14,IF(Entity="Choice 2",LEN([Textbox])=11,IF(Entity="Choice 3",LEN([Texybox])=8,IF(Entity="Choice 4",LEN([Textbox])=8))))

*Entity beiing the name of the choice column containing choice 1-4

*Textbox being the name of the column containing numbers.

 

Within the column validation I ran the below:

=AND(ISNUMBER([Textbox]+0),LEN([Textbox])>7)

 

Worked a treat, thanks for your help

 

Reply