Memberstack
Pricing
API
Login
Build for free
Memberstack
Pricing
API
Login
Build for free
Memberstack
Pricing
API
Login
Build for free
Blog/How to Validate an Input Against a List of Approved Values

How to Validate an Input Against a List of Approved Values

This post will teach you how to validate an input against a list of approved values, why this validation is important, and how to implement it in your Webflow site.

Ovidiu·Contributor
|
February 27, 2025·3 min read

How to validate an input against a list of approved values

Other use-cases using Memberscript #127

https://docs.google.com/document/d/1AXazZfgQ2SJ0H0UHQKI9zZuTbbd7y0-9swKRjXIu4hQ/edit?tab=t.0

Memberscripts needed

https://www.memberstack.com/scripts/validate-text-inputs

Tutorial

Cloneable

__wf_reserved_inherit

Why/Use Cases

- Ensure users input data that is appropriate for a specific form field and communicate errors as they type.

Validating users’ field inputs on a Webflow site

Form fields are usually expected to receive a certain type of data input (e.g. ZIP code), but users can sometimes get it wrong, often by accident (e.g. typos).

Validating form inputs will immediately inform users if the data they’ve entered is wrong or unexpected and this guide will show you how to validate a field input against a list of approved values.

This works by first providing a list of acceptable inputs or patterns and then comparing users’ inputs against with list to ensure it matches.

To create a form field with validation on your Webflow site, we’re going to use MemberScript #127 – Validate Text Inputs. Follow the link to get the code you’ll need to add to your page and watch a video tutorial on how to set everything up.

Setting it up

First off, you’ll need to build and style your form and add the following attributes to the field you want to have validation on:

· ms-code-require=”zip” – we’re only using “zip” for the purpose of this guide, but it’s just an identifier that you can name however works best for your input type

· ms-code-require-list=”VALUE” – possible values discussed below

· maxlength=”5” – this will simply limit the number of characters the input can have

For the list of acceptable values, simply enter a comma-separated list of values (e.g. 10000,10001,10002, etc.) or use certain variables to tell the field what type of inputs it should accept.

Variables are described like this: {a0A}. In this example, an acceptable input is 3 characters long, with the first character being a lowercase letter, the second a number, and the third an uppercase letter. Some examples of acceptable inputs are: v8Q, w4Z, r9D, etc.

These can be used in various ways, for example:

· 100{00} – any five-digit number that starts with 100; the last two digits can be anything

· abc{aA} – any five-letter word that starts with abc and ends with a lowercase letter followed by an uppercase letter

· 0000} – any four-digit number

· aaaaa} – any lowercase five-letter word

Next, create and style an error message (can be a simple div block) for unacceptable inputs below the field and add the following attribute to it:

· ms-code-require-error=”zip”

Optionally, you can also add this attribute to the submit button:

· ms-code-submit-button=”zip”

This lowers the submit button’s opacity to 50% until the ZIP field receives an acceptable input, while also making the button unclickable.

Making it work

Now that you’ve got everything set up in Webflow, all you need to do is add the MemberScript #127 custom code to your page, before the closing body tag.

Conclusion

That’s all you need to do, you can now test the form fields on your live site.

If you want to use our demo project to get you started, just click the button below to add it to your Webflow site.

Our demo can help you validate your users’ form inputs against a custom list of values on your Webflow site.

Blog image

Take me to Cloneable!‍

Written by

Ovidiu

Contributor

Contents

  • Other use-cases using Memberscript #127
  • Memberscripts needed
  • Tutorial
  • Cloneable
  • Why/Use Cases
  • Validating users’ field inputs on a Webflow site
  • Setting it up
  • Making it work
  • Conclusion
  • Take me to Cloneable!‍

Share

Explore Memberstack

  • All Features
  • Customer Showcase
  • Templates
  • Find Experts
  • Pricing
  • Help Center

Product

  • Full Feature List
  • User Accounts
  • Gated Content
  • Secure Payments
  • API & Integrations
  • Data Tables
  • Memberstack & Webflow
  • Memberstack & Claude Code
  • Memberstack & WordPress
  • Create a new account
  • 2.0 Log in
  • 1.0 Log in
  • Pricing

Learn about Memberstack

  • Showcase
  • Testimonials
  • Why Memberstack
  • Memberstack vs Outseta
  • Memberstack vs Memberspace
  • Memberstack vs Webflow Memberships

Company

  • About
  • Careers
  • Changelog
  • Partnerships(email)
  • Contact Us(email)
  • X
  • LinkedIn
  • "Do Not Sell My Data" Promise

Resources

  • Vibe Coding
  • Templates
  • Components
  • MemberScripts
  • Data Attributes
  • Find Experts
  • Hiring Guide
  • Webflow Slack Community
  • WordPress Slack Community
  • Support Forum
  • Help Center
  • Blog
  • llms.txt (for AI)
  • llms-full.txt (for AI)
AICPA
SOC

SOC 2 TYPE 1

CERTIFIED

GDPR

COMPLIANT

CCPA

COMPLIANT

Privacy PolicyTerms of ServiceCookie PolicySecurity Policy

© Memberstack Inc. 2018 - 2025. All rights reserved.

Memberstack - The no-code membership platform for any website | Product Hunt