Tip 31: How to make a field in a Zoho Creator form mandatory based on criteria

Tip 31: How to make a field in a Zoho Creator form mandatory based on criteria

Hi folks,

 

I'm sure most of you are familiar with the Mandatory property available in our form builder. It enables you to ensure that your users enter an input in a required field. If they don't enter an input in that field, they'll be unable to submit the form. All you need to do is select the required field and just enable (check the box) the Mandatory property that you'll find in the Field Properties pane.



Whenever a mandatory field is left empty during form submission, a default alert message will pop up and prevent form submission.

                                                         

This remains static for all users and doesn't override on any condition. However, there is a way to bypass this and allow a form to be submitted even without the mandatory field value. This tip will help you understand how to make a field mandatory based on a particular condition or criteria.

Let's take the example of an Employee Leave Form, which employees use to apply for leave. Regardless of the number of days employees plan to take off or have already taken, they need to add a record using the Employee Leave Form while applying for leave. While entering the details, they can choose from different leave types available. By default the five basic categories are: Sick Leave, Casual Leave, Compulsory Off, On Duty, and Others. The employees can choose Others if their reason doesn't fall in any of the above choices. However, if the employee selects the Others option and submits the form, the person approving the leave needs to know the reason to either approve or reject it. 

If you mark the Leave Type field as mandatory, this wouldn't work if the user chooses the Others option. Hence, we've come up with a workaround—marking a field mandatory based on a condition using Deluge. 

Let's go through it step by step.

Step 1: Create the form, with all the required fields

First, let's create a Leave Form to capture all the details. Here, we've used the following fields:
  •  Name (Name Field)
  •  Email (Email Field)
  •  Employee ID (Single Line field)
  •  Start Date (Date Field)
  •  End Date (Date field)
  •  Leave Type (Radio Button)
  •  Reason (Multi Line Field)
Please note that the Reason field is used to enable employees to enter the reason for their leave if they select the "Others" option in the Leave Type field.




Step 2: Hide the Reason field when the form loads

 

Whenever the employee selects Others in Leave Type , they need to fill in the reason for it in the Reason  field. However, we can hide the field otherwise and show it only when the employee selects Others. To do that, we can create a simple workflow on the "Created or Edited - Load of the Form" condition using the below script.



  1. hide Reason;


Step 3: Show the Reason field only when the employee selects the Others option

 

As mentioned earlier, if the user selects the Others option in the Leave Type field, then the Reason field needs to be shown. For that, create a workflow in "Created or Edited - User input of field" on the Leave Type field using the the below script.

  1. if(input.Leave_Type == "Others")
  2. {
  3.  show Reason;
  4. }
  5. else
  6. {
  7.  hide Reason;
  8. }


Step 4: Mark the required field as mandatory using Deluge

 

Here comes the important part of configuring the Reason field as mandatory whenever the user selects Others as the leave type. For this, we can use a simple if statement to validate the leave type and prompt them to enter the reason. If the users selects the Others option, they have to enter details in the Reason field as well.

 

If the Reason field is empty, then we can display an alert asking the user to fill in the reason for their leave. Create a workflow with "Created or Edited - Validation on form submission" and this part of the workflow will get triggered once the user clicks the Submit button of the form.

  1. if(input.Leave_Type == "Others" && input.Reason == "")
  2. {
  3. alert(Reason,"Kindly mention the reason for the leave");
  4. cancel submit;
  5. }
Check the below-image to see how the validation works in the live form and the alert gets displayed. On clicking the Submit button, a validation will run to check if the Reason field is left empty. If it is empty, it will prevent form submission and an alert message will be shown in the pop-up.



In order to notify the user which field has to be filled, we're using the Inline Alert. Once the user clicks the OK button in the above error pop-up, an alert with our customized message will be displayed below the respective field, as shown in the image below.


We hope you try out this tip out for when you need to make a field mandatory based on conditions. We'll get back to you soon with another useful tip!


    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts





                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources

                                                                                              Zoho Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ




                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方







                                                                                                              • Recent Topics

                                                                                                              • French Tutorials

                                                                                                                Is there any Zoho projects tutorials, ebook, video or else in french? If so, where can I fin it please? Thx
                                                                                                              • My zoho mail has been disabled and cannot send email

                                                                                                                I’m the super admin for my company’s email accounts, but my own email address has been unexpectedly locked. I’m seeing the following error message: Could you please assist in unlocking my account so I can resume sending emails?
                                                                                                              • SMTP error

                                                                                                                I am using SMTP from Zoho the account is accounts@khlaklaeeb.com it was working fine then started to have Error and unable to delivery messages SMTP host SMTP.zoho,com SMTP user: accounts@khlaklaeeb.com SMTP port 465 PAssword: App Password it was working
                                                                                                              • Automatically creating a ticket in Zoho Desk when an invoice is created in Zoho Books

                                                                                                                I need to find a way to create a ticket automatically (i.e. using workflow) in Zoho Desk whenever an invoice is created in Zoho Books. Please advise if there is a way of doing that?
                                                                                                              • Been getting this error, every now and then "Get count limit exceeded, please try again after 3 mins"

                                                                                                                it is really annoying.
                                                                                                              • Co-existing with Google Workspace

                                                                                                                We currently use GWS and due to legacy practices, we cannot migrate away from it. Not easily anyway. The issue we have is that while we have Zoho Mail, we get duplicate copies of emails. Our setup is that GWS is our primary. We have Zoho MX records in
                                                                                                              • Stop Zoho Projects From Automatically Adding Client Users

                                                                                                                I have a custom function that creates a Zoho Project for every Quote attached to a Deal when it moves to Closed Won. Everything works fine, except for the fact that connecting a Zoho Project to the CRM automatically takes the Contact associated with the
                                                                                                              • dd Linked Note to Comments & History via Custom Function + Zoho Document View Feature

                                                                                                                Hi all, I have a couple of custom functions running in Zoho (specifically in Inventory/Books), and I'm trying to streamline it. Here’s the scenario: When a Purchase Receive is processed, my custom function automatically creates a Package. I'd like to
                                                                                                              • How to break line in zohoCRM

                                                                                                                Hello everyone, I'm currently working with Deluge scripting language and encountering an issue with newline characters (\n). My goal is to format a string with multiple lines, but the newline characters are not being interpreted correctly. Instead of
                                                                                                              • Marketer’s Space: Supercharged Workflow with Zoho CRM Integration

                                                                                                                Hello Marketers! Welcome back to another post in Marketer’s Space. Today, we’ll explore how integrating Zoho CRM with Zoho Campaigns can help you create smarter, more personalized Workflow. In this post, we’ll look at a specific use case to demonstrate
                                                                                                              • Zoho Live chat doesnt chat on CRM Contact page????

                                                                                                                We have used Salesforce Live Agent for the last 8 years and the chat comes in on the Contact record which is logical and intuitive as the chat agent can see the customers sales history and open opportunities...etc... We just migrated to Zoho CRM and I
                                                                                                              • Image Quality Issue on Zoho Assist

                                                                                                                Hello, For the past two days, I've been experiencing a significant image quality issue on Zoho Assist when connecting to one of my computers. I’ve tried reinstalling the application, but the issue persists across multiple devices. The internet connection
                                                                                                              • New views to manage activities within a record

                                                                                                                Dear customers, We hope you're well! Today, we're here with a useful update to the Activities related list. As you might be aware, parent records display related information from other modules as related lists. This helps you get a 360-degree view of
                                                                                                              • Sent Mail not in "Sent" IMAP folder

                                                                                                                I have configured ZOHO to use IMAP. When I send an email from within Zoho, the email does not show up in my "Sent" IMAP folder. Every email client I have ever used, stores sent mails in the "Sent" folder. This is a serious flaw!  Please fix this ASAP! Oliver
                                                                                                              • Admin Control for Subscribing Users to Bots in Zoho Cliq

                                                                                                                Hello, I would like to request an enhancement to Zoho Cliq, specifically related to subscribing users to bots. Current Issue: When using the Zoho Desk integration with Cliq, notifications such as Mentions, Happiness Ratings, and Pending Blueprint Transitions
                                                                                                              • Eighth Insight - Oversee module relationships with Lookups

                                                                                                                The Wheels of Ticketing - Desk Stories Oversee module relationships with Lookups ‌Learning about lookups A lookup field provides a powerful way to display and utilize data from another module directly within a field of your current module. This functionality
                                                                                                              • New capabilities for custom buttons: Elevate UX and CX with just a click!

                                                                                                                -------------------------------------------------Post moderated on 24th May-------------------------------------------------------------- Dear all, The feature is now available for all users in all DCs. Dear Customers, We hope you're well! We're happy
                                                                                                              • Client Side Scripts for Meetings Module

                                                                                                                Will zoho please add client side scripting support to the meetings module? Our workflow requires most meeting details have a specific format to work with other software we have. So we rely on a custom function to auto fill certain things. We currently
                                                                                                              • CRM APP

                                                                                                                So the crm can now have image uploads. Great for us doing site surveys and linking them to customers. Unfortunatley the crm app does not show the image fields.  Any ideas of must we create a form and then link that?
                                                                                                              • Zia Summary for Account - What is its reach

                                                                                                                Hello! I've been working with the Zia summary feature and it's very useful. However, it seems to pull in notes and things directly "on" the Account. If I have a meeting or phone call and provided detailed summaries with the event associated to the account,
                                                                                                              • Search a custom module record based on a date range

                                                                                                                Hi , I hope you can share some guidance. I need to look up a record from a custom module based on the Closing Date of a Deal (in the Deals module). Here’s the context: 1. I have a custom module that stores quarterly values (e.g., rates or thresholds).
                                                                                                              • How do I associate an expense to multiple projects?

                                                                                                                How do I associate itemized expenses to multiple projects, like assigning each line to the respective project
                                                                                                              • So what's the limit?

                                                                                                                Recently our team encountered an error popping out when sending a service report. Although the report was sent successfully to zoho desk but the site asset record isn't updated. We notice this error occur only when line items [subform record] exceeds
                                                                                                              • Charge to add client users to a ZOHO Project?

                                                                                                                Is there a charge to add client users to access a zoho project portal?  An additional license charge or any other additional costs?  Thank You
                                                                                                              • Zoho CRM Notifications API - Channel Expiry

                                                                                                                Has anyone built a reliable integration with CRM Notification API (https://www.zoho.com/crm/developer/docs/api/v8/notifications/overview.html)? Need to sync CRM data with my external system and prefer not to use CRM workflows which ist a nice low code
                                                                                                              • Create Tasks in arbitrary Zoho Project triggered from CRM [Zoho CRM]

                                                                                                                Community, hello What I'm trying to do is to create a Zoho Project when a Deal is created in CRM and then to be able to add tasks to this Project also from Zoho CRM with the trigger (Blueprint/ Workflow). I succeeded in creating Project using Zoho Flow,
                                                                                                              • job opening status is locked and and I cannot change it

                                                                                                                Dear Support I am using standard plan. The job opening status is locked and and I cannot change it.
                                                                                                              • IDN domain

                                                                                                                Why I can't use my domain www.blažek.com I do not want use unfolded shape www.xn--blaek-wib.com in my mail. Can you help me please?
                                                                                                              • Gmail - Error 553 Relaying Disallowed

                                                                                                                Hey Zoho, I have just set up my mail server and added a couple of email accounts. I've verified my domain and added the mx records with my registrar (namecheap.com) What I'm trying to do is to be able to send email from my domain through Gmail.  In Google
                                                                                                              • Candidate status change

                                                                                                                I am trying to change candidate status from "interview scheduled" to "hired". Where do I do this at?
                                                                                                              • How can I set up my contacts so that all users can have them on hand when they sign in?

                                                                                                                Hi.  For my business I would like to set up the Contacts so they are available for any user. 
                                                                                                              • Sharing Knowledge Base articles across multiple departments

                                                                                                                It would be useful to share some Knowledge Base articles across multiple departments where they are applicable, rather than having to go into other departments to find the article you're looking for. For example. Our reception uses the 'Admin' desk whereas our IT guys use the 'Support' desk, however both divisions would find KB articles about our company intranet useful. Reception does not have access to the support desk, so cannot see articles created in the Support KB. Perhaps you could install
                                                                                                              • Where do we manage tags?

                                                                                                                Where is the page where we can view all tags and manage them (like change a tag name to something else or merge tickets under a particular tag with another)?
                                                                                                              • Custom Return Path - Host Name

                                                                                                                Hi there, I've successfully set up SPF/ DKIM for Marketing Automation, but struggling to complete the Custom Return Path. I'm settting up on Wix. What should the host name be for the CNAME record? In Zoho Help it just says: "type your host name (sub-domain
                                                                                                              • How to send Messages to Leads/customers

                                                                                                                I’d like to inquire about the process for sending messages or follow-up communications to customers directly from Zoho CRM. Could you please guide me on the best way to do this—whether via email, SMS, or any integrated messaging feature? Additionally,
                                                                                                              • Daily-rate for projects

                                                                                                                I am billing my client through daily billing rates; for Zoho Books projects, only hourly rates can be set up. Please enhance this. Thanks.
                                                                                                              • Admin Console Email

                                                                                                                I can't remember the admin console email or password. How do I find that out?
                                                                                                              • help me! the button "remove zoho ad" is not responding

                                                                                                                help me! the button "remove zoho ad" is not responding, kindly advice. please to check the follows : https://sitepreview-643549202.zohositescontent.com/previewsite https://sitebuilder-643549202.zohositescontent.com/builder thanks,best  regards
                                                                                                              • Zoho Forms API

                                                                                                                Is there any way to get all form entry list using API? Looking forward to hear from you
                                                                                                              • Free tier

                                                                                                                Does a completely free tier Zoho email still exists? If so why am I receiving email reminders that my account would expire in 2 days
                                                                                                              • Next Page