1

I have this form:

<form data-ajax="true" data-ajax-method="post"  
    data-ajax-url="@(Url.Action("DeleteUserModel", "AccountAdmin"))"
    data-ajax-mode="replace" data-ajax-update="#deleteDiv"
    data-ajax-loading="#ajax" data-ajax-failure="failed"
    data-ajax-success="ondeletesuccess">
     <input type="hidden" name="userName" value="@user.UserName" />
     <input type="submit" class="btn btn-danger" onclick="ConfirmDelete"
            value="Delete" />
 </form>

and the javascript in the main page:

<script>
  function ConfirmDelete() {
      var result = confirm("Are you sure to delete?");
      if (!!result) {
          return true;
      }
      return false;
  }
</script>

But the form deletes the record without showing confirmation. how to correct this?

mz1378
  • 1,957
  • 4
  • 20
  • 40

1 Answers1

0

Replace "ConfirmDelete"in your code with function "ConfirmDelete()" defined as...

function ConfirmDelete() {
      var result = confirm("Are you sure to delete?");
      if (!!result) {
          return true;
      }
      return false;
  }
nischal sharma
  • 479
  • 1
  • 14