- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2016 05:34 AM
Hi
I have a text field and it has 2 questions for example like below
Question 1
Question 2
Now I have to validate that both questions are answered , both Questions have question text , how this can be done ?
TIA
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 06:05 AM
You COULD do it with a regular expression similar to what I have below (and check for both answer[1] and answer[2] to be non-empty/non-undefined values. The thing is, if someone messes with your text, the pattern fails and they won't be able to continue. This is why I recommend two fields. That being said, here's a RegEx that should do what you want as long as they don't mess with your questions.
var input='1)What steps has been taken to resolve the issue\n' +
'None\n'+
'2)What steps has been taken to confirm issue never reoccurs\n' +
'Eat more vegetables\n';
var patt = /1\)What steps has been taken to resolve the issue\n(.*)\n2\)What steps has been taken to confirm issue never reoccurs\n(.*)\n/;
var answers = input.match(patt);
gs.print(input);
gs.print(answers.length);
gs.print('answer1=' + answers[1]);
gs.print('answer2=' + answers[2]);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2016 05:39 AM
Can you provide an example of the text you are trying to parse? I'm not sure I fully understand the issue. (There may be other solutions based on what the underlying requirement is.)
What would you like to do with the information once it is parsed? Is it being validated that the questions are answered?
It would seem to be easier to use two question fields and two answer fields, or if the list varies in length, how about a table that can be used as a related list?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2016 08:57 PM
Hi Chuck
The whole idea for parsing is to validate if both questions had been answered or not , having two diff fields are not feasible ATM.
Example of quetions
1)What steps has been taken to resolve the issue
2)What steps has been taken to conrfirm issue never reoccurs

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2016 05:33 AM
Is the question text always EXACTLY the same every time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 02:30 AM
Yes, its the same always