onChange for multi line text fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2009 05:49 AM
I am having an issue with the onChange script running on a multi line text field, it seems to fire onLoad but not if I change the content of the field and tab out? The specific script is running against work around on the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2009 04:14 PM
Textarea fields work a little bit differently than regular text fields. The way that it should work is to have the onChange event fire when the focus leaves the field. As it is, Service-now doesn't even attach an onChange event to textarea fields. You can attach your own event to a textarea field though using client scripting. I have done this before and added an 'onKeyUp' event (which fires each time you press and release a key) to mimic an 'onChange' event. You should be able to set the onchange event (which should fire when the field loses focus) this way as well. Here's a sample script. It should be set up as an 'onLoad' client script so that it can attach the event to the textarea element.
function onLoad() {
//Attach a custom event to the 'comments' textarea element
//Get the control
var control = g_form.getControl('comments');
//Set its onkeyup method
control.onkeyup = myCustomFunction;
}
function myCustomFunction(){
//Do regular client script stuff for your custom event here
}