Jump to content

jquery on 'click' confirm not working


Recommended Posts

i have a flow of registration forms with an 'exit' url on each page, which allows the users to exit before the full registration is complete. before following the click URL, i want an 'are you sure' confirmation message to be displayed to the user. if 'yes' then the click URL would be loaded; if 'no' then nothing would happen.

i have the following html/jquery code in the footer of forms that are part of the registration process:

<a class="exits" href="https://c1dcs255.caspio.com/dp/0db19000a392125dc37d41b6a8ab">exit</a>

<script type="text/javascript">
    $('.exits').on('click', function () {
        return confirm('Are you sure? Your order will not be registered.');
    });
</script>

straightforward as this seems, i can't get it work. i never get a confirmation popup.

 

Link to comment
Share on other sites

Hello @aaronfreed,

I am afraid that I cannot help with jquery code.

As for me, I usually add EventListeners to the Footer section like this:

<script >

document.addEventListener('DataPageReady', onClickHandler);

function onClickHandler() {
    const exitLink = document.querySelector('.exits');
    exitLink.addEventListener('click', confirmMessage);
}

function confirmMessage(event) {
    const conf = confirm('Are you sure? Your order will not be registered.');
    if (conf == true) {
        window.location = "https://c1dcs255.caspio.com/dp/0db19000a392125dc37d41b6a8ab";
    }
}

</script>

You may check if this solution works as expected. 

Maybe someone will help with the jquery version. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...