One of the simplest ways to debug client script is to use the alert functionality. alert simply pops up a message window displaying information you choose to include. This can be useful for showing the values of fields or variables at certain times, or simply to confirm that certain functions were entered.
Let's see how alert works in the following code:
alert('Debug Message');
The preceding script will simply show a pop-up message to the user saying Debug Message. It is a simple line of code to write and provides instant feedback.
Let's have a look at how we can use alert to help us test our code:
function onLoad() {alert('Start of script');var shortDescBefore = g_form.getValue('short_description');alert('The short description beforehand ...