onsubmit only if mandatory fields were filled.

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Alex
Posts: 32
Joined: Fri Jun 30, 2017

26 Mar 2018

Hi, I'm trying to accomplish following scenario.

On a new form I added a function, triggered by fd.onsubmit. Problem is that my form has a few SharePoint standard mandatory fields, if they are not filled the form will not be sent, but my event will trigger anyways.

Is it possible to trigger only on a successfully submitted form?

regards

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

26 Mar 2018

Dear Alex,
The issue is that the check for mandatory servers happens on the server, after the JavaScript onsubmit works. Since it happens after, the only option to ensure that it works is to add code to onsubmit block that will check the mandatory fields on its own and will only work if all fields are filled in properly.
Cheers

Alex
Posts: 32
Joined: Fri Jun 30, 2017

26 Mar 2018

Hi Nikita, ok I understand...

is there a function to iterate through all mandatory fields or do I have to do something like jQuery("input[title~='Required Field']").each() ?

regards

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

26 Mar 2018

Dear Alex,
The best way depends on how many mandatory fields you have and what's their type. Easiest way would be to manually check all the fields by getting the data from them, but if you have a large number of fields or need to do it for many lists and need a more flexible solution, let us know. For getting data from fields, check out the following article - https://spform.com/javascript-framework ... eld-values
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests