Skip to main content
steffena0001
Known Participant
Jan 5, 2022 5:20 AM UTC
Solved

Add specific validation to text

Hi! Just wanna ask how can I make the text file only accept values that are in this format

1.1.1

1.2.2

etc

Participating Frequently
Jan 5, 2022 6:48 AM UTC

You can use regex functions to match with specific text pattern and use its result for displaying validation on the text field. 

{
  a!textField(
    label: "Release Version",
    labelPosition: "ABOVE",
    value: ri!value,
    saveInto: {
      ri!value      
    },
    refreshAfter: "UNFOCUS",
    validations: {
      if(
        regexmatch(
          "^(\d+\.)(\d+\.)(\*|\d+)$",
          ri!value
        ),
        {},
        "Enter correct format XX.XX.XX"
      )
    }    
  )
}

Use this web based tool to explain / understand the regex pattern - https://regexr.com/

8 replies

Participating Frequently
Jan 5, 2022 6:48 AM UTC

You can use regex functions to match with specific text pattern and use its result for displaying validation on the text field. 

{
  a!textField(
    label: "Release Version",
    labelPosition: "ABOVE",
    value: ri!value,
    saveInto: {
      ri!value      
    },
    refreshAfter: "UNFOCUS",
    validations: {
      if(
        regexmatch(
          "^(\d+\.)(\d+\.)(\*|\d+)$",
          ri!value
        ),
        {},
        "Enter correct format XX.XX.XX"
      )
    }    
  )
}

Use this web based tool to explain / understand the regex pattern - https://regexr.com/

steffena0001
Known Participant
Jan 5, 2022 8:08 AM UTC

Thank you very much! worked perfectly!