How to use confirm dialog box with two buttons ok and cancel in JavaScript

1 Answer

0 votes
<!DOCTYPE html> 
<html> 
<script>
function message() {  
    var r = confirm("Are u sure?");  
    if (r === true){  
        document.write("ok");  
    }  
    else {  
        document.write("cancel");  
    }
}
</script>  
<body>
<input type="button" value="delete account?" onclick="message()"/>
</body> 
</html>

 



answered Oct 8, 2019 by avibootz
...