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

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

  
Forge Component
(24)
Published on 19 Sep (3 days ago) by Marcelo Ferreira
24 votes
Published on 19 Sep (3 days ago) by Marcelo Ferreira

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.


tks in advance

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:

1. MaskText - from Custom Masks widget

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:

1. MaskText - from Custom Masks widget

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


Thanks for your reply.

What do you enter in the field 'MaskDefinition, if you use regex code in AdvancedOptions?

Paul. wrote:

Pedro Costa wrote:

I used:

1. MaskText - from Custom Masks widget

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


Thanks for your reply.

What do you enter in the field 'MaskDefinition, if you use regex code in AdvancedOptions?


Sorry for late, late answer.  :x

Probably you already get answer for your question, but just for history i just let empty the 'MaskDefinition field when i use regex in AdvancedOptions.

For easy maintenance e used site propertie in AdvancedOptions.