I am allowing the user to input a description. What I am needing is to split up the string they input based on 27 characters.
So if their description is less than 27 characters....
It is a single string and needs to alert them of that.
If their description is more than 27 but less than 54 characters....
I need it to find the space closest to the 27th character, then split the string into 2 lines
If their description is more than 54 but less than 81 characters....
I need it to find the space closest to the 54th character, then split the string into 3 lines
If their description is more than 81 but less than 108 characters....
I need it to find the space closest to the 81st character, then split the string into 4 lines
If their description is more than 108 characters....
Alert that it is really long
Here is a section of code I am working with
for (z = 0; z < theDocVariables.length; z++) { // Start finding variables here if (theDocVariables[z].name == "coverPageDecriptionLineOne") { if (getText(titleDescription).length < 27){ alert("single line"); } if (getText(titleDescription).length > 27 && getText(titleDescription).length < 54){ alert("two line"); } if (getText(titleDescription).length > 54 && getText(titleDescription).length < 81){ alert("three line"); } if (getText(titleDescription).length > 81 && getText(titleDescription).length < 108){ alert("four line"); } if (getText(titleDescription).length > 108){ alert("that's a long freakin description"); } alert("Your title is " + getText(titleDescription).length + " characters in it"); }