cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

How to stop page refresh or redirecting while submitting webform?

I have a created a webform for account entity with some steps.

 

In the last step while submitting the form I have ajax code to add a record for my custom entity with account id. 

 

The ajax request is failing because of page refreshing. I want to stop the page refresh or page redirecting until my custom entity's record is saving. 

 

I have added following code:

 

if (window.jQuery) { (function ($) { if (typeof (webFormClientValidate) != 'undefined') { var originalValidationFunction = webFormClientValidate; if (originalValidationFunction && typeof (originalValidationFunction) == "function") { webFormClientValidate = function() { originalValidationFunction.apply(this, arguments); // do your custom validation here // return false; // to prevent the form submit you need to return false // end custom validation. return true; }; } } }(window.jQuery)); }

 

I have added the above code in my last step as custom JavaScript but code doesn't work because webFormClientValidate is getting undefined. Wherever I place this code webFormClientValidate getting undefined. 

 

any suggestion?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft
Microsoft

Hi @shahriat,

Just remove the undefined check, there does seem to be a current issue where the code to establish that function is not being included in Web Forms. Another community user ran into the same.

f (window.jQuery) { (function ($) { if (typeof (webFormClientValidate) != 'undefined') { var originalValidationFunction = webFormClientValidate; if (originalValidationFunction && typeof (originalValidationFunction) == "function") { webFormClientValidate = function() { originalValidationFunction.apply(this, arguments); // do your custom validation here // return false; // to prevent the form submit you need to return false // end custom validation. return true; }; } } }(window.jQuery)); }

$(document).ready(function () {
  webFormClientValidate = function () {
    $.ajax(....);
  };
});

View solution in original post

2 REPLIES 2
Microsoft
Microsoft

Hi @shahriat,

Just remove the undefined check, there does seem to be a current issue where the code to establish that function is not being included in Web Forms. Another community user ran into the same.

f (window.jQuery) { (function ($) { if (typeof (webFormClientValidate) != 'undefined') { var originalValidationFunction = webFormClientValidate; if (originalValidationFunction && typeof (originalValidationFunction) == "function") { webFormClientValidate = function() { originalValidationFunction.apply(this, arguments); // do your custom validation here // return false; // to prevent the form submit you need to return false // end custom validation. return true; }; } } }(window.jQuery)); }

$(document).ready(function () {
  webFormClientValidate = function () {
    $.ajax(....);
  };
});

View solution in original post

Hi Justin,

Thanks a lot for your valuable response.

I need another help, like in the step2 I have a map where I draw shapes. Before going to final step I want to pass a json with those shapes to final step. 

 

Could you please help how can I pass json data to the 3rd step?

 

-

Thanks

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Users online (32,363)