In JavaScript, the programmer has some interesting options regarding native feature, some of them are very helpful especially for simple functions of daily interaction with the user that some pages may need. The command ALERT, CONFIRM AND PROMPT are clear examples of this type of resource.

ALERT

The dialog ALERT serves to show an information and only has a button to close. This feature is often used to display messages to the user possible, especially in cases where there are errors in filling out forms or information processing. See below for an example of code ALERT:

<SCRIPT LANGUAGE=”javaScript” type=”text/javaScript”>
alert (“Hello, this is an ALERT box.”)
</ SCRIPT>

CONFIRM

Unlike ALERT, CONFIRM the box returns a Boolean value (true or false) for that particular action is performed. Using the buttons “OK” and “Cancel” certain action can be performed, just that an IF is created validating the information returned from CONFIRM, check below a practical example:

<SCRIPT LANGUAGE=”javaScript” type=”text/javaScript”>
var = return confirm(“Choose an option.”);

if (back) {
alert (“You clicked on OK button!”);
}else {
alert (“You clicked on Cancel button”);
}
</ SCRIPT>

PROMPT

This dialog box is used to test more code blocks, from a data entry user can perform certain processing. This feature has been replaced by text fields, so you will hardly use it on a daily basis, but nevertheless it is important to know what this feature does. Check out the example:

<SCRIPT LANGUAGE=”JavaScript” type=”text/JavaScript”>
var name;
do {
name = prompt (“What is your name?”);
} While (name == null | | name == “”);
alert (“Your name is” + name);
</ SCRIPT>

javascript

There are countless resources that JavaScript language features, so it is important to understand well on its operation. Often a problem can be solved with a simple method exists in the native language.

Want to test our examples and still learning how to use other features of a web development tool more powerful in the world? Then download the free version now Scriptcase and meet a world of possibilities.

You might also like…

How to implement A2F using Own Development in NodeJS in a Scriptcase application

A2F using Own Development in NodeJS A2F: In a previous article, we talked about Swivel as an extern...

Specialists or generalists, who gets a better advantage by using Scriptcase?

Hey there! Today  we will figure what are the ideal profiles for those who wish to take advantage o...

Disabling autofill and autocomplete Chrome browser in login screens

Hello, here I want to show an alternative to disable the autofill and autocomplete of the chrome bro...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.