Confirmation of form action

Asked

Viewed 39 times

1

I have this code to delete a bank record. How can I put a jquery (yes no) form action confirmation in my code?

 $('#deleteButton').on('click', function(e){
               // We don't want this to act as a link so cancel the link action
               e.preventDefault();
               doDelete();
           });

1 answer

2


You can use the confirm(mensagem) of Javascript, which shows a message (defined by you) to the user and click on Ok she returns true, click on Cancelar she returns false:

$('#deleteButton').on('click', function(e){
    // We don't want this to act as a link so cancel the link action
    e.preventDefault();

    if (confirm('Realmente deseja excluir o registro?')) {
        doDelete();
    }
});

The layout of the confirmation window of this function is the default browser, if you want something better elaborated, create a custom modal (bootstrap you find several) for you and do it with the same logic.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.