onChange Event Scripting Best Practice?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 10:13 AM
I haven't really figured out how to do this with SN's client scripts. Is there as way to create an onChange event script? Think... character counter or cc number field that displays a changing info message based on character changes as a user types instead of waiting until the user focuses away from the field. Is there a best way to do this with a client script?
Thanks!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 12:37 PM
Hi, Yes you can write onChange on any field ( column ) of form.
If you want something asynchronous way then use the GlideAjax method to process the input value and get the desire result.
Check this link for GlideAjax
https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f96196e
Thanks,
Ashish
Please mark correct answer and helpful for other if it helps you
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 12:46 PM
I mean, before you leave focus of the field. Event listener kind of thing. GlideAjax will run onLoad or onChange after the field changes and the user clicks out of the field but not each time a character is entered.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 12:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 12:49 PM
Yeah, that's catch. Think incident form in workspace where it warns you of character count until N number of minimum characters are reached. I know of the property you can set to show remaining characters in description field, but that's total out of 4000. I want to show the message until the minimum 30 characters are reached.