JS: Make fields not-mandatory based on user selection?
-
- Posts: 4
- Joined: Wed Feb 14, 2018
Hey guys,
I'm fairly new to the form designer and new to coding, but I was wondering if there was a simple code solution to this problem.
I have a 3 tab onboarding form. One tab contains general info, so the persons name address etc, one tab for contractor info, and one tab for employee info. No person can be an employee AND contractor at the same time, but I would still like to enforce mandatory fields within the individual tabs.
My idea is to have a question in the general info tab saying "Contractor or Employee", and when contractor is selected, the employee tab is no longer relevant and the mandatory field checks INSIDE the employee tab are no longer checked on submit. This would mean the form would still be dummy proof (enabled mandatory fields within each section), but more optimized.
Does the API include some way to do this in javascript?
Any ideas would be much appreciated
Thanks-David C
I'm fairly new to the form designer and new to coding, but I was wondering if there was a simple code solution to this problem.
I have a 3 tab onboarding form. One tab contains general info, so the persons name address etc, one tab for contractor info, and one tab for employee info. No person can be an employee AND contractor at the same time, but I would still like to enforce mandatory fields within the individual tabs.
My idea is to have a question in the general info tab saying "Contractor or Employee", and when contractor is selected, the employee tab is no longer relevant and the mandatory field checks INSIDE the employee tab are no longer checked on submit. This would mean the form would still be dummy proof (enabled mandatory fields within each section), but more optimized.
Does the API include some way to do this in javascript?
Any ideas would be much appreciated
Thanks-David C
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear David,
This is more than possible to do with JavaScript, but there is one limitation - the mandatory fields should be made so with JavaScript, not in SharePoint. It's impossible to overwrite what fields are required by SharePoint, so it cannot be undone by JavaScript. But it is possible to not save the form, unless some fields are filled in based on some condition, and give user an error warning about it.
Read this article for more details on how to conditionally make fields mandatory - https://spform.com/javascript-framework ... ynamically
This is more than possible to do with JavaScript, but there is one limitation - the mandatory fields should be made so with JavaScript, not in SharePoint. It's impossible to overwrite what fields are required by SharePoint, so it cannot be undone by JavaScript. But it is possible to not save the form, unless some fields are filled in based on some condition, and give user an error warning about it.
Read this article for more details on how to conditionally make fields mandatory - https://spform.com/javascript-framework ... ynamically
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 14 guests