Forums

Forums / Bugs & Issues / Form Reload whenever the validate event Returns False

Form Reload whenever the validate event Returns False

8 posts, 0 answered
  1. Kerillos Kamel
    Kerillos Kamel avatar
    17 posts
    Registered:
    24 Jun 2022
    06 Sep 2022
    Link to this post
    I'm validating some logic on the form before the submission using "tpc:validate" Event but when I return false to prevent user from submission if there is an error the form reloaded and the user lose all the date he entered how can I prevent the form form reloading again when the "tpc:validate" event return false ??
  2. Ian Pekunsal
    Ian Pekunsal avatar
    11 posts
    Registered:
    04 Jul 2022
    06 Sep 2022 in reply to Kerillos Kamel
    Link to this post
    Hello Kerillos,

    Thanks for reaching out through the forums.
    Could you please try event.prevent default inside the tpc:validate snippet?
    Also please confirm the submit button is a TPC widget and not the default button.

    Thanks.
  3. Kerillos Kamel
    Kerillos Kamel avatar
    17 posts
    Registered:
    24 Jun 2022
    06 Sep 2022 in reply to Ian Pekunsal
    Link to this post
    Hi Ugur, 
      thanks for your quick response.
    I have added that line 'event.preventdefault' and I added the TPC Submit button widget instead  but I can't find away to trigger this button to submit the form from another button using JS see snippet :
            $("#seai_submitbutton").on('click', function () {
            debugger;

            tpc.forms[0].TpcSubmitButtonController_0.add_click();
            $('#C065_Col00 > div > TpcSubmitButtonController_0').trigger("click");
        });
    although this was working on the submit button widget 
    Last modified on 06 Sep 2022 15:09 by Kerillos Kamel
  4. Ian Pekunsal
    Ian Pekunsal avatar
    11 posts
    Registered:
    04 Jul 2022
    06 Sep 2022 in reply to Kerillos Kamel
    Link to this post
    You can use the submit button API to trigger it.
    Simply put the function you want to run in a variable and pass it as a parameter to the add_click() call.

    https://www.crmportalconnector.com/developer-network/documentation/portal-connector-widgets/tpc-client-side-api/forms-based/submit-button
  5. Kerillos Kamel
    Kerillos Kamel avatar
    17 posts
    Registered:
    24 Jun 2022
    06 Sep 2022 in reply to Ian Pekunsal
    Link to this post
    I want to fire the submission itself not calling a function on Submission of a form the reason for that because I'm using a different custom button to submit the form while the TPC out of the box Submit button is hidden so I was using this snippet here '  $('#C065_Col00 > div > button').trigger("click");' to trigger the submission of the form but using the MVC Submit button but as I was advise to use TPC Submit button instead I found that this code is not working ?
  6. Kerillos Kamel
    Kerillos Kamel avatar
    17 posts
    Registered:
    24 Jun 2022
    07 Sep 2022 in reply to Kerillos Kamel
    Link to this post
    I have been able to trigger the submission but still reloading the page even after using the TPC Submit button and event.preventDefault(); !! 
  7. Kerillos Kamel
    Kerillos Kamel avatar
    17 posts
    Registered:
    24 Jun 2022
    22 Sep 2022
    Link to this post
    Any Updates??
  8. Omar S
    Omar S avatar
    51 posts
    Registered:
    04 Jul 2019
    07 Oct 2022 in reply to Kerillos Kamel
    Link to this post
    Hello Kerillos
    Assuming you are using MVC widgets, please use the tpc:pre-validate event handler to check the validity of the form.
    Form Submission events
    Last modified on 12 Oct 2022 14:10 by Omar S
8 posts, 0 answered