must()
Enforce complex input criteria.
Setup
Attribute: sf-validation="must(number, lowercase, uppercase, symbols)"
Where: Applied to input
elements like password
, email
, etc.
Validates that the input meets specified criteria for characters. Ensures inputs c=ontain a combination of numeric, lowercase, uppercase, and special characters as defined.
Please note: must()
validation should be applied to the following input types: text
, email
, textarea
, password
, color
, search
.
HTML Example
Webflow Example
Usage Examples
must(1,2,1,0)
: At least 1 number, 2 lowercase characters, 1 uppercase character, and no symbols are required.must(0,1,1,1)
: At least 1 lowercase character, 1 uppercase character, and 1 symbol are required, with no number requirement.must(any,1,1,1)
: No limit on numbers, at least 1 lowercase character, 1 uppercase character, and 1 symbol are required.must(1,any,1,0)
: At least 1 number, no limit on lowercase characters, 1 uppercase character, and no symbols are required.
Attribute Configuration
Here are some instructions to keep in mind:
Ensure to format the attribute value as
must(number,lowercase,uppercase,symbol)
where each parameter defines the minimum count required for:number: Numeric characters
lowercase: Lowercase alphabetic characters
uppercase: Uppercase alphabetic characters
symbol: Special characters or symbols
All four arguments are required.
must()
validation can be paired with native HTML attributes likepattern
,maxlength
, orminlength
.You can pass
any
to indicate no limit for a specific criterion.
Dos and Dont's
Do ✅
must(1,2,1,0)
must(0,1,1,1)
must(any,1,1,1)
must(1,any,1,0)
Don't ❌
must(null,2,1,0)
: Don't use alphabetic characters as arguments, except forany
.must(1 , 2, 1 , 0)
: Don't use spaces.must(1,2)
: Don't use fewer than 4 arguments.must(1,2,1,0,1)
: Don't use more than 4 arguments.must(1.5,2.5,1.5,0)
: Don't use fractional numbers.
Last updated