Skip to content
the poor coder

are you sure alert js

Poor Man
Published
Reading time
1 min read

Are You Sure Alert JS?#

As a web developer, I have come across situations where I needed to confirm the user's decision before proceeding with an action. This is where the "Are you sure alert" comes into play. It is a simple JavaScript function that displays a pop-up message to the user asking if they are sure they want to proceed with the action.

The syntax for this function is quite simple:

Text

function areYouSure(){
   var confirmation = confirm("Are you sure you want to proceed?");
   if (confirmation == true) {
      //code to execute if user clicks "Ok"
   } else {
      //code to execute if user clicks "Cancel"
   }
}

In this function, we first declare a variable called "confirmation" and assign it the value returned by the "confirm()" function. This function takes a message as an argument and displays a pop-up with an "Ok" and "Cancel" button. If the user clicks "Ok", then the value of "confirmation" will be true, otherwise it will be false.

We then use an "if" statement to check the value of "confirmation". If it is true, then we can execute the code that we want to run if the user confirms the action. If it is false, then we can execute the code that we want to run if the user cancels the action.

There are other ways to achieve the same result using different JavaScript functions such as "window.prompt()" or by creating a custom modal window. However, the "Are you sure alert" is a simple and effective way to confirm user decisions without having to add any additional libraries or code.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC