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.
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
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
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:
Worked a treat, thanks for your help