Page 1 of 1
onsubmit only if mandatory fields were filled.
Posted: 26 Mar 2018
by Alex
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
Re: onsubmit only if mandatory fields were filled.
Posted: 26 Mar 2018
by Nikita Kurguzov
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.
Re: onsubmit only if mandatory fields were filled.
Posted: 26 Mar 2018
by Alex
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
Re: onsubmit only if mandatory fields were filled.
Posted: 26 Mar 2018
by Nikita Kurguzov
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