Rather than using JavaScript alert(), for a cleaner look, you’ll display error on the form field itself. The methods showFieldMsg() and hideFieldMsg() it will to display a message just under the field itself.
showFieldMsg and hideFieldMsg are methods which will be used with the g_form object.
These methods are accustomed change the view of records (Incident, Problem, Change forms). These methods may be available in other client scripts, but must be tested to work out whether or not they work as expected.
When a field message is displayed on a form on load, the form scrolls to confirm that the field message is visible. Ensuring that users don’t miss a field message because it had been off the screen.
The global property glide.ui.scroll_to_message_field controls automatic message scrolling when the form field is offscreen (scrolls the form to the control or field).
You can either use switch statement of if else statement
Switch Statement Script
function onChange(control, oldValue, newValue, isLoading) {
switch (newValue) {
case 'create_app':
g_form.showFieldMsg('request_type', 'Ticket for the service to create an app.', 'info'); // give here your variable name and display message
break;
case 'deploy':
g_form.showFieldMsg('request_type', 'Ticket for deployment of app.', 'info'); // give here your variable name and display message
break;
case 'add_user':
g_form.showFieldMsg('request_type', 'Ticket for the creation of a new user.', 'info'); // give here your variable name and display message
break;
case 'add_dyno':
g_form.showFieldMsg('request_type', 'Ticket for adding more dynos units to the app.', 'info'); // give here your variable name and display message
break;
}
}

If Else Statement Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
g_form.hideFieldMsg('request_type'); // // give here your variable name and display message
if(newValue == 'create_app'){
g_form.showFieldMsg('request_type', 'Ticket for the service to create an app., true); // give here your variable name and display message
}
else if(newValue == 'deploy'){
g_form.showFieldMsg('request_type','Ticket for deployment of app.', true); // give here your variable name and display message
}
else if(newValue == 'add_user'){
g_form.showFieldMsg('request_type','Ticket for the creation of a new user.', 'info');, true); // give here your variable name and display message
}
else if(newValue == 'add_dyno'){
g_form.showFieldMsg('request_type','Ticket for adding more dynos units to the app., true); // give here your variable name and display message
}
}
I hope all the information shared above related to ServiceNow script for display message with example will be helpful.