I’m building an app in Glide (Business Plan) and I’ve run into a frustrating issue with both ID Number and Phone Number fields.
What I’m trying to do:
I want each input screen to only show a “Continue” button when the following conditions are met:
For ID Number:
• Must be exactly 10 digits
• Must start with 1 or 2
• Must not be a duplicate (already submitted before)
For Phone Number:
• Must be exactly 10 digits
• Must start with 05
• Must not be a duplicate
When the input is valid, the button should appear and move to the next page.
What’s going wrong:
I’ve tried many methods including regex, template columns, and computed logic, but Glide still gives me problems:
• Leading zeros are removed from numbers, so “0582137008” becomes “582137008”
• Length checks return wrong results (e.g., 9 instead of 10)
• Even when everything looks correct, the visibility logic doesn’t trigger
• Template columns still behave like numbers sometimes
I even tried using forced text and invisible characters, but it’s not working reliably.
What I need help with:
• How can I treat the input as true text, keeping leading zeros and avoiding silent conversion to numbers?
• What’s the most reliable way to extract and validate the first digit or two from an input field?
• How can I check for duplicates in the same Glide table before allowing submission?
• Is there a cleaner, proven method that doesn’t rely on tricky workarounds?
I don’t mind rebuilding the logic from scratch. I just want a clean and stable solution that works consistently.
Thank you very much in advance. I’ve already spent many hours trying and I really appreciate any help from the community.
The JavaScript column. You could probably prompt Claude or another AI tool to generate JavaScript code to perform the validations you need (if JavaScript can do it, I don’t know).
Perhaps the custom AI component and experiment with including the validation within the component directly. I have no idea if this is possible.
function validateIdNumber(idString, existingIds) {
const errors = [];
if (typeof idString !== 'string') {
return "Input must be a string";
}
if (!/^\d+$/.test(idString)) {
errors.push("ID must contain only digits");
}
if (idString.length !== 10) {
errors.push("ID must be exactly 10 digits long");
}
if (/^\d+$/.test(idString) && idString.length === 10) {
if (!idString.startsWith('1') && !idString.startsWith('2')) {
errors.push("ID must start with 1 or 2");
}
if (existingIds.includes(idString)) {
errors.push("ID already exists");
}
}
return errors.join(', ');
}
return validateIdNumber(p1, p2)
function validatePhoneNumber(phoneString, existingPhones) {
const errors = [];
if (typeof phoneString !== 'string') {
return "Input must be a string";
}
if (!/^\d+$/.test(phoneString)) {
errors.push("Phone number must contain only digits");
}
if (phoneString.length !== 10) {
errors.push("Phone number must be exactly 10 digits long");
}
if (/^\d+$/.test(phoneString) && phoneString.length === 10) {
if (!phoneString.startsWith('05')) {
errors.push("Phone number must start with 05");
}
if (existingPhones.includes(phoneString)) {
errors.push("Phone number already exists");
}
}
return errors.join(', ');
}
return validatePhoneNumber(p1, p2)
You might want to change the “input must be a string” part to something like input must not be empty.
Assuming you have a table where you store already used ID Numbers (and the same for Phone Numbers), here are some thoughs about a possible approach (my fellows mentioned some others).
The idea is to store the value, before applying controls/tests. And the button visibility will be based on the result of all tests.
I’ll showcase it for ID Number because it’s exactly the same logic for Phone Number.
Data part
Add the following columns to the User table:
Input value (Number or Text or even Phone Number) to store the value entered in the form.
Be careful if you use Number to uncheck “Use group separator” or adjust the next steps accordingly.
Length (Text Length). Select the User Profile > Input value column as the source.
Startswith (Text Slice). We want the first character on the left, so you slice it to get 1 character (Length) from the position 0 (Start), because we count from 0 in JavaScript (the coding langage behind this feature in Glide).
Related ID Number (Relation) to find if this value already exists. We need to verify inside my ID Numbers table the column named Number (change it to match yours). If there is at least a match, you’ll see something inside the column, else nothing (which is my case in this screenshot).
From now on, we want to return true if the test is OK and false if not. We’ll apply the same logic 3 times, because there are 3 conditions
Must be 10 digits (If → Then → Else), where we check if we have exactly 10 digits (if you have a Number column, the Number entry will prevent User to add other type of content… else, you should probably add some other controls here, to avoid a letter for example).
Must start with 1 or 2 (If → Then → Else). Idem, this time with a “is included in” and “1, 2”. For Phone Number, you might want to replace it by a “is” condition (and 05 as value).
Must not be a duplicate (If → Then → Else). The condition this time is to return true if the Related ID Number column is empty (meaning we haven’t found anything similar to the entered value)
Next steps are optional but I strongly recommend them for UX/UI Design purpose. It will be helpful to guide your users.
Create 3 If → Then → Else columns. One for each test. We’ll write a message for explaining the user what’s OK and what is not when he/she fill the form. I named them 10 digits, Starts 1 or 2 and Not duplicate and I was very inspired for the messages as you can see:
The number is 10 digits length The number must be 10 digits length
The number starts with 1 or 2 The number must start with 1 or 2
To make is user friendly, we group all the messages inside a Template column Displayed Message. You can apply a more robust naming convention, mine is quite basic here:
A
B
C
and the replacements are A → 10 digits, B → Starts 1 or 2 and C → Not duplicate
The last 2 steps are mandatory again. We create an aggregation of all tests and we calculate the final output to let Glide know if the button must be visible or not (data part).
Test results (Make Array). Quite easy to understand: here we bring back the 3 test results (true or false for each one of them). If you have another test to add, you get the logic, you add it by clicking on “Add item”.
Final test result, a Find Element Index column. You try to find a value “false”. If the column is not empty, it means we really have a test returning false… so that’s not good. If there are only true values, then the result is an empty cell. It’s the same thing as for the Relation we created earlier to find duplicated value (or not).
3 Add the Button. In the Action, click on Add condition, select the `````Final test result```` column (from the User Profile again) and choose “is empty” as conditon.
Thank you all so much for your time and ideas — every suggestion was helpful and gave me great perspective on how to approach this. Special thanks to those who shared screenshots and code — your input really helped shape my logic in a clean and effective way. I truly appreciate the generosity and support from this community!
Thank you for sharing this. I had never thought of doing this before.
I like the approach with the JavaScript column. It feels robust and “simple” enough once the correct code defined. But it’s code.
And I really like your approach with computed columns only. It feels a tad less robust than code and it feels like computed columns won’t be able to cover all edge cases, but the way you do it elegant.