# [Custom Masks] Doubt to do a mask for alphabetical and 1 special character

Forge Component

(22)
Published on 7 Mar by Jogait
Published on 7 Mar by Jogait

Hi, i already try several times without success.

I need build a validation for:

1. alphabetical and "-"   like "test-f", with maximum of 50 characters and no whitespaces.

Other doubt is:

2. decimal and ".", only one "." like "2.1" or "0,1234568" or "0.2", with maximum of 8 decimals and no whitespaces.

For the 2nd part I guess you would go for a regular expression. There is a system action for comparing a regular expression against an input.

A regular expression that could work for the 2nd part is:

([0-9](\.|,){0,1}[0-9]{0,8})

[0-9] = starting with a digit
(\.|,){0,1} = zero or 1 occurrences of . or ,
[0-9]{0,8} = ending with 0 to 8 occurrences of a digit

Use tools like http://regexr.com/ to build and test your regular expressions.

Solution

Paul Kruyt wrote:

For the 2nd part I guess you would go for a regular expression. There is a system action for comparing a regular expression against an input.

A regular expression that could work for the 2nd part is:

([0-9](\.|,){0,1}[0-9]{0,8})

[0-9] = starting with a digit
(\.|,){0,1} = zero or 1 occurrences of . or ,
[0-9]{0,8} = ending with 0 to 8 occurrences of a digit

Use tools like http://regexr.com/ to build and test your regular expressions.

Thanks Paul.

I already founded solution for my problem :)

I used:

regex code in AdvancedOptions: {regex:'^([A-Za-z0-9]+[-?])+([A-Za-z0-9])+\$', placeholder: '' }

2. DecimalOnlyInput - wb from Custom Masks widget.

*The max characters were forgotten

Solution

Pedro Costa wrote:

I used: