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:
- /*
- Validate if the candidate is between 18 and 30 years old
- Function: dtnascimento
- Map: ValidaDtNascimentto
- */
- entityMap = recruitAPIRequest.toMap().get("record");
- response = Map();
- // Get the Date of Birth field value
- dtNascimento = entityMap.get("Data_de_nascimento");
- if (dtNascimento != null)
- {
- // Calculate age
- today = zoho.currentdate;
- age = today.getYear() - dtNascimento.getYear();
- // Adjust if the birthday hasn't happened yet this year
- if ((today.getMonth() < dtNascimento.getMonth()) ||
- (today.getMonth() == dtNascimento.getMonth() && today.getDay() < dtNascimento.getDay()))
- {
- age = age - 1;
- }
- // Check if age is out of range
- if (age < 18 || age > 30)
- {
- response.put("status", "error");
- response.put("message", "You must be between 18 and 30 years old to apply.");
- return response;
- }
- else
- {
- response.put("status", "success");
- return response;
- }
- }
- else
- {
- // When the field is empty
- response.put("status", "error");
- response.put("message", "Please fill in your date of birth.");
- return response;
- }
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!