You can display a standard alert box with a single OK button by calling the alert function. Use alert boxes for serious or potentially fatal errors, but do not overuse them. Alert boxes require user input. Therefore, they can be annoying, especially when they report minor errors or obscure the entry that needs to be corrected.
Use alert boxes to warn users that the action about to begin can destroy data or can be time consuming. Alert boxes of this sort should give users a choice of proceeding or canceling the action. If the alert box offers users a choice, such as Proceed or Cancel, you must construct it yourself.
If the alert box provides users with a choice, the text in the alert box should first describe the problem and then pose the next action as a question. In such cases it is important that the button for proceeding be labeled with a verb that describes what will happen. In this context, Overwrite, for example, is less ambiguous than OK, and is an aid to experienced users who will gloss over the text because they have seen this alert box many times.
Unless the error is truly fatal, provide a way for users to return to a previous step or escape from the operation that triggered the alert box.
Usually the default button for a dialog box is OK or its equivalent, but when the situation described by the alert box has serious consequences, make Cancel or its equivalent the default.