Prevent double quotes and 'enter' key in mutliline field

LG21
Giga Contributor

We need to prevent users from entering double quotes and the "enter" key (ie a new line) into a comments field which is multiline.

We've created an on change client script, but the alert displays even if there is no double quote or new line in the field. 

We've tried to use an example from another post but can't seem to get the correct values in the regEx var?

Our script is:

//check for double quotes or new line/enter
var str = g_form.getValue('u_comments');
var regEx = /"\n\r/;
var valid = regEx.test(str);
if(!valid)
alert('The comments field must not contain double quotes or Enter/New Line');

return false;
}

 

the alternative option is to replace double quotes and 'enter' with a space when the form is submitted - so happy to have that option as well.

 

thanks

1 ACCEPTED SOLUTION

If you want to do this in a client script you could use JavaScript indexOf() to determine if a quote exists. Something like this untested code:

var comment = g_form.getValue('u_comment');

if (comment.indexOf('"') >= 0) {
    alert('Hey, there is a quote here. Not good');
}

Footnote on the dictionary attribute, it caps the string limit at 255 characters, but for a comment, that's still a lot.

View solution in original post

8 REPLIES 8

perfect! thank you - have a great weekend!

Hi Chuck,

 

could you please elaborate on the steps that are required to create such an "is_multi_text=false" attribute?

It is not in the Dictionary Attributes table (sys_schema_attribute_list) out of the box so I cannot select it directly on a field dictionary entry, and there are quite a few values that one need to determine if you would like to add it (label, name, applies to, on table, column type, value type).


Many thanks in advance!
Tamas

SzTamas
Tera Contributor

I've found the solution:
https://www.youtube.com/watch?v=GelWXWy6Jc4&t=1941s

The key is to click "advanced view" so you can insert the attribute in the text field that appears.
You should not look for this feature in the related lists.

/ Sorry, duplicate /