Validation function not preventing candidates under 18 or over 30 from submitting the web form

Validation function not preventing candidates under 18 or over 30 from submitting the web form

Hello everyone,

I’m trying to create a validation rule for the Candidate Webform in Zoho Recruit.

I added a custom field called “Date of Birth”, and I want to make sure that candidates cannot submit the form unless their age is between 18 and 30 years.

I created a custom Deluge function for this purpose, named dtnascimento, and my map name is ValidaDtNascimentto.
However, even after setting up the validation rule and linking it to this function, the webform still accepts all submissions — even if the candidate is younger than 18 or older than 30.

Here’s the code I’m currently using:

  1. /*
  2. Validate if the candidate is between 18 and 30 years old
  3. Function: dtnascimento
  4. Map: ValidaDtNascimentto
  5. */

  6. entityMap = recruitAPIRequest.toMap().get("record");
  7. response = Map();

  8. // Get the Date of Birth field value
  9. dtNascimento = entityMap.get("Data_de_nascimento");

  10. if (dtNascimento != null)
  11. {
  12.     // Calculate age
  13.     today = zoho.currentdate;
  14.     age = today.getYear() - dtNascimento.getYear();

  15.     // Adjust if the birthday hasn't happened yet this year
  16.     if ((today.getMonth() < dtNascimento.getMonth()) || 
  17.         (today.getMonth() == dtNascimento.getMonth() && today.getDay() < dtNascimento.getDay()))
  18.     {
  19.         age = age - 1;
  20.     }

  21.     // Check if age is out of range
  22.     if (age < 18 || age > 30)
  23.     {
  24.         response.put("status", "error");
  25.         response.put("message", "You must be between 18 and 30 years old to apply.");
  26.         return response;
  27.     }
  28.     else
  29.     {
  30.         response.put("status", "success");
  31.         return response;
  32.     }
  33. }
  34. else
  35. {
  36.     // When the field is empty
  37.     response.put("status", "error");
  38.     response.put("message", "Please fill in your date of birth.");
  39.     return response;
  40. }

But the validation is not triggering — the form still accepts dates outside the 18–30 range.

Could anyone please confirm:

If the validation rule for Recruit Webforms actually block form submission?

Or if there’s a different way to enforce this rule for the Date of Birth field in a webform?

Thanks in advance for your help!


    • Sticky Posts

    • How to Add Users to your Organization in ZohoMail?

      A better clarity so you can create other users to start using Zoho Mail. You can directly Add Users from the Control Panel to your Organization. You can invite users with the existing email address. If the person (user) already uses ZohoCRM, then you can import users from Zoho CRM. You can also import them using a .csv file. (if you are planning to add them in Bulk)  In this topic, We will be discussing on how to Add and Invite users only.  The Import options are self explanatory. ____________________________________________________________________________________________________________