
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I set a form action to show Field B if a text Field A contains a string. I would like to hide Field B if the string only occurs once in Field A. Can javascript or appscript accomplish this?
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
this will determine if Field A has 1 occurrence of "the string" (in any case) and hide Field B if so, otherwise it will show field B.
var matches = GetFieldValue("Field A").match(/the string/gi) ;
if ( matches !== null && matches.length === 1) {
HideField("B");
} else {
ShowField("B");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Yes, definitely you can do such validations in java script / App script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thank you. That's encouraging. I wonder what would that look like in javascript and appscript.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
this will determine if Field A has 1 occurrence of "the string" (in any case) and hide Field B if so, otherwise it will show field B.
var matches = GetFieldValue("Field A").match(/the string/gi) ;
if ( matches !== null && matches.length === 1) {
HideField("B");
} else {
ShowField("B");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thank you.
Would the 'if' statement that follows test for field "B" as empty?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I suppose I could set another variable instead of hiding or showing field "B"?