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





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner






                                                            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 Writer

                                                                                              Get Started. Write Away!

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

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Windows Desktop App - request to add minimization/startup options

                                                                                                              Support Team, Can you submit the following request to your development team? Here is what would be optimal in my opinion from UX perspective: 1) In the "Application Menu", add a menu item to Exit the app, as well as an alt-key shortcut for these menus
                                                                                                            • How do I filter contacts by account parameters?

                                                                                                              Need to filter a contact view according to account parameter, eg account type. Without this filter users are overwhelmed with irrelevant contacts. Workaround is to create a custom 'Contact Type' field but this unbearable duplicity as the information already
                                                                                                            • Unified customer portal login

                                                                                                              As I'm a Zoho One subscriber I can provide my customers with portal access to many of the Zoho apps. However, the customer must have a separate login for each app, which may be difficult for them to manage and frustrating as all they understand is that
                                                                                                            • WhatsApp Channels in Zoho Campaigns

                                                                                                              Now that Meta has opened WhatsApp Channels globally, will you add it to Zoho Campaigns? It's another top channel for marketing communications as email and SMS. Thanks.
                                                                                                            • Is it possible to customize ZC Themes?

                                                                                                              I understand you can choose a layout and customize Brand Color, App Header, Menu, and Sub-Menu components, but can you override some of the default theme settings with CSS or a config file? For example, - Table highlight color - Listview auto filter highlight
                                                                                                            • error : Object code : 6500

                                                                                                              b3 = map(); b3.put("name", "Test Project Name"); updateprojects2 = invokeurl [ url :"https://projectsapi.zoho.eu/restapi/portal/era0130/projects/169495000000928007/" type :PUT parameters: b3 connection:"in2" ]; info b3 ; info updateprojects2; ------------
                                                                                                            • Tracking KPIs, Goals etc in People

                                                                                                              How are Zoho People users tracking employee targets in People? For example, my marketing assistant has a target of "Collect 10 new customer testimonials every month". I want to record attainment for this target on a monthly basis, then add it to their
                                                                                                            • Text snippet

                                                                                                              There is a nice feature in Zoho Desk called Text Snippet. It allows you to insert a bit of text anywhere in a reply that you are typing. That would be nice to have that option in Zoho CRM as well when we compose an email. Moderation Update: We agree that
                                                                                                            • Is it possible to create Custom function-based Lookup field in Zoho CRM

                                                                                                              Is it possible to create a custom function-based lookup field in Zoho CRM? If so, how? Use case: Need to fetch users from Zoho Projects into a dropdown field in Zoho CRM.
                                                                                                            • Zoho Projects app update: Voice notes for Tasks and Bugs module

                                                                                                              Hello everyone! In the latest version(v3.9.37) of the Zoho Projects Android app update, we have introduced voice notes for the Tasks and Bugs module. The voice notes can be added as an attachment or can be transcribed into text. Recording and attaching
                                                                                                            • Create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM

                                                                                                              How to create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM? I was able to do a view in CRM based on customer that registered to an event, but I don't seems to be able to include the filter
                                                                                                            • How can I see content of system generated mails from zBooks?

                                                                                                              System generated mails for offers or invices appear in the mail tab of the designated customer. How can I view the content? It also doesn't appear in zMail sent folder.
                                                                                                            • How to conditionally embed an own internal widget with parameters in an html snippet?

                                                                                                              Hello everyone, I'm trying to create a dynamic view in a page using an HTML snippet. The goal is to display different content based on a URL parameter (input.step). I have successfully managed to conditionally display different forms using the following
                                                                                                            • Zadarma + Zoho CRM Integration – Missed Calls Saved as Contacts Instead of Leads

                                                                                                              Hello everyone, I’m looking for input from anyone with experience using the Zadarma + Zoho CRM integration. Currently, I’m seeing that missed calls are automatically being created as Contacts instead of Leads. From a CRM perspective, this doesn’t make
                                                                                                            • Custom Button Disappearing in mobile view | Zoho CRM Canvas

                                                                                                              I'm working in Zoho CRM Canvas to create a custom view for our sales team. One of the features I'm adding is a custom button that opens the leads address in another tab. I've had no issue with this in the desktop view, but in the mobile view the button
                                                                                                            • Search Records returning different values than actually present

                                                                                                              Hey! I have this following line in my deluge script: accountSearch = zoho.crm.searchRecords("Accounts","(RS_Enroll_ID:equals:" + rsid + ")",1,200,{"cvid":864868001088693817}); info "Account search size: " + accountSearch.size(); listOfAccounts = zoho.crm.searchRecords("Accounts","(RS_Enroll_ID:equals:"
                                                                                                            • Function 56: Automatically enable the option for customers to pay via bank account

                                                                                                              Hello everyone and welcome back to our series! One of the key features of Zoho Books is its integration with multiple payment gateways, allowing you to receive online payments for your invoices. This ensures faster payments, automates payment tracking
                                                                                                            • Attach Files to Your Notecards and share them on the go!

                                                                                                              Hey everyone! We’re excited to share a feature many of you have been asking for — you can now attach files directly to your text notecards and share with ease! 🙌 This update was built with your feedback in mind, especially for those who wanted a simple
                                                                                                            • Can i connect 2 instagram accounts to 1 brand?

                                                                                                              Can i connect 2 instagram accounts to 1 brand? Or Do i need to create 2 brands for that? also under what subscription package will this apply?
                                                                                                            • Workdrive on Android - Gallery Photo Backups

                                                                                                              Hello, Is there any way of backing up the photos on my android phone directly to a specific folder on Workdrive? Assuming i have the workdrive app installed on the phone in question. Emma
                                                                                                            • Integración Books para cumplir la ley Crea y Crece y Ley Antifraude (VeriFactu)

                                                                                                              Hola: En principio, en julio de 2025, entra en vigor la ley Crea y Crece y Ley Antifraude (VeriFactu). ¿Sabéis si Zoho va a cumplir con la ley para cumplir con la facturación electrónica conectada a Hacienda? Gracias
                                                                                                            • YouTube Live #1: AI-powered agreement management with Zia and Zoho Sign

                                                                                                              Hi there! We're excited to announce Zoho Sign’s first YouTube live series, where you can catch the latest updates and interact with our Zoho Sign experts, pose questions, and discover lesser-known features. We're starting off by riding the AI wave in
                                                                                                            • Mass Mail Statistics - Number of unsent emails

                                                                                                              How do I find out which emails were not sent?
                                                                                                            • How to add a % Growth column for year-over-year comparison (2024 vs 2025)

                                                                                                              Hello, I am trying to build a monthly revenue comparison between 2024 and 2025 in Zoho CRM Analytics. My current setup is: Module: Deals (Affaires) Filter: Stage = Closed Won Date field: Closing Date Grouping: By Month Metrics: Sum of Amount for 2024,
                                                                                                            • How to searchByCriteria records that are under approval?

                                                                                                              I need to search for both approved and pending approval records Is that possible with this method? Or I need to a different method? var priceReqID = $Page.record_id; log(priceReqID); var records = ZDK.Apps.CRM.Price_List_Item.searchByCriteria("Price_Request:equals:"
                                                                                                            • Power of Automation::Streamline log hours to work hours upon task completion.

                                                                                                              Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                                                                                            • How to add Simple Analytics to Zoho Pages?

                                                                                                              I have a website with Zoho Pages, how do I add Simple Analytics on it? They seem to have code they need to be embedded https://docs.simpleanalytics.com/script
                                                                                                            • Product details removed during update from other system

                                                                                                              We maintain our product details in an other system. These details are synchronized with Zoho at the end of each day, through an API. This has worked perfectly sofar. But last Monday, all product codes and some other product data have been wiped during
                                                                                                            • End Date in Zoho Bookings

                                                                                                              When I give my appointments a 30 minutes time I would expect the software not to even show the End Time.  But it actually makes the user pick an End Time.  Did I just miss a setting?  
                                                                                                            • I hate the new user UI with the bar on the left

                                                                                                              How can I reverse this?
                                                                                                            • Cant seem to delete an email account

                                                                                                              Hello, I have researching for 4 days how to delete an email account and I am absolutely without a clue. The email account I am trying to delete is support<AT>fyshoes<dot>com. It's the first email account I made and it (is???) was associated with the super user (me). I have since changed it to adming<AT>fychoes<dot>com and I see the support email in my list but I just cant seem to get rid of it. Ultimately I want to associate that email account with another user that I want to add. This is really
                                                                                                            • Commerce Order as Invoice instead of Sales Order?

                                                                                                              I need a purchase made on my Commerce Site to result in an Invoice for services instead of a Sales Order that will be pushed to Books. My customers don't pay until I after I add some details to their transaction. Can I change the settings to make this
                                                                                                            • Sync desktop folders instantly with WorkDrive TrueSync (Beta)

                                                                                                              Keeping your important files backed up and accessible has never been easier! With WorkDrive desktop app (TrueSync), you can now automatically sync specific desktop folders to WorkDrive Web, ensuring seamless, real-time updates across devices. Important:
                                                                                                            • Script that deletes a record?

                                                                                                              We're using WP Plugin "Integration for WooCommerce and Zoho Pro", and have created a couple of Feeds to send data to Zoho. We are trying to create Contact records, but only based upon condition. Tried to make it with small Deluge function and Workflow,
                                                                                                            • Introducing Profile Summary: Faster Candidate Insights with Zia

                                                                                                              We’re excited to launch Profile Summary, a powerful new feature in Zoho Recruit that transforms how you review candidate profiles. What used to take minutes of resume scanning can now be assessed in seconds—thanks to Zia. A Quick Example Say you’re hiring
                                                                                                            • Import data into Multi-Select lookup field from CSV/Excel

                                                                                                              How to import data into a multi-select lookup field from the CSV/Excel Sheet? Let's say I have an Accounts multi-select lookup field in the Deals module and I want to import the Deals with Accounts field. Steps:- 1. Create/edit a multi-select lookup field
                                                                                                            • Auto Capitalize First Letter of Words

                                                                                                              Hi I am completely new to ZOHO and am trying to build a database. How can i make it when a address is entered into a form field like this: main st it automatically changes is to show: Main St Thank You
                                                                                                            • A formula that capitalises the first letter of each word

                                                                                                              Hi all, is there a zoho formula that can capitalise the first letter of each word in a string? INITCAP only capitalises the first letter of the first word.
                                                                                                            • Add Analytics function for Title case (capitalising each word in a string)

                                                                                                              At present, you can only capitalise each word in a string in Analytics during data import. It would be really useful to be able to do this with a formula column, but there is no Title Case function.
                                                                                                            • Office 365 and CRM mail integration: permission required

                                                                                                              Has anyone run into this weird problem? My email server is Office 365. When I try to configure Zoho CRM to use this server, a Microsoft popup window opens requesting user and password. After entering that, I get a message in the Microsoft window saying
                                                                                                            • Next Page