The CreatorCon Call for Content is officially open! Get started here.

when we use client script types in Servicenow

Dinesh Kumar C
Tera Contributor

I see there are 4 types in client scripts

1.onLoad

2onChange

3.onSubmit

4.onCellEdit

When we use these functions in which scenario we segregate these functions ? For eg To validate mobile number format we can use onSubmit and onChange . Where is the exact difference between these 4 .

Thank you

1 ACCEPTED SOLUTION

PriyaRanji
Tera Guru

Hi Dinesh,



Good Day



Client Script : it will works in client (browser) side. Please find the details below for more information.



onLoad()



An onLoad() script runs when a form is first drawn and before control is given to the user to begin typing. Typically, you use an onLoad() script to perform some client side manipulation of the document on screen.



onChange()



An onChange() script can run when a particular field changes value or when the form is first drawn and no fields have changed value from previous script actions. As such, onChange scripts can potentially act as onLoad scripts with extra conditions.



onCellEdit()



Scripts can be defined as onCellEdit to run on the client side when the list editor interacts with a cell.



onSubmit()



An onSubmit() script runs when a form is submitted. Typically, you use an onSubmit() script to validate things on the form and ensure that the submission makes sense. As such, onSubmit()scripts can potentially cancel a submission by returning false.



To validate mobile number format :- please refer the below thread which helps you out!



Client side number validation



Thanks,


Priyanka R


View solution in original post

10 REPLIES 10

PriyaRanji
Tera Guru

Hi Dinesh,



Good Day



Client Script : it will works in client (browser) side. Please find the details below for more information.



onLoad()



An onLoad() script runs when a form is first drawn and before control is given to the user to begin typing. Typically, you use an onLoad() script to perform some client side manipulation of the document on screen.



onChange()



An onChange() script can run when a particular field changes value or when the form is first drawn and no fields have changed value from previous script actions. As such, onChange scripts can potentially act as onLoad scripts with extra conditions.



onCellEdit()



Scripts can be defined as onCellEdit to run on the client side when the list editor interacts with a cell.



onSubmit()



An onSubmit() script runs when a form is submitted. Typically, you use an onSubmit() script to validate things on the form and ensure that the submission makes sense. As such, onSubmit()scripts can potentially cancel a submission by returning false.



To validate mobile number format :- please refer the below thread which helps you out!



Client side number validation



Thanks,


Priyanka R