Hide multiple field messages on same variable with hidefieldmessage

ctsmith
Mega Sage

If a user types in the wrong text in a field, a field message appears.   After they enter the right text in the variable, the hidefieldmessage() clears out the field message.   But, what if they enter the wrong text more than once.   There are two or more field messages, but once they enter the correct text, hidefieldmessage() only clears one of the field message entries.   How do you clear them all out for a variable if there is more than one field text entry?

User enters the wrong text twice:

find_real_file.png

Thanks!


Chris

1 ACCEPTED SOLUTION

Andras Kisgyorg
Kilo Guru

Hello Chris,



hideFieldMsg() can have an optional clearAll parameter to hide all field msgs of the given field,


as described in this wiki article with example:


http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#hideFieldMsg



Please let me know if that helped.


Best regards,


Andras


View solution in original post

4 REPLIES 4

Chris M3
Tera Guru

Reorganize the client script a bit to resolve this.


g_form.hideFieldMessage('variable');


if (newValue != 'goodValue')


g_form.showFieldMessage('variable');



This way, everytime the on-change script is called, the first thing it does is hide any messages.   Then it evaluates and displays the message again if the newValue still does not match.


Also, bingo.   I thought this out a bit more, and this is good option.   This prevents multiple messages from being generated in the first place.   Thanks!


Andras Kisgyorg
Kilo Guru

Hello Chris,



hideFieldMsg() can have an optional clearAll parameter to hide all field msgs of the given field,


as described in this wiki article with example:


http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#hideFieldMsg



Please let me know if that helped.


Best regards,


Andras


Bingo.