Skip to content Skip to sidebar Skip to footer

Onclick Confirm Not Working

Hello I have this line of code. onClick='confirm('Are you sure you want to update the database to the latest version?')'>

Solution 1:

You must use return confirm(...) instead of just confirm(...) for it to work.


Solution 2:

Confirm function actually returns a boolean. It's true if the user clicks ok, and false if cancel is clicked.
So you need to save the return value of confirm function in a variable, and then check that variable to perform desired operations.


Post a Comment for "Onclick Confirm Not Working"