Hoppa till huvudinnehållet

How can I validate a number falls with in a specified range?

Kommentarer

5 kommentarer

  • Stefan Schweigert

    Hello Thomas,

     

    It looks as though you are on the right track. It is possible to set a Default Value for the Number form element, and check the 'Required' checkbox but this won't allow users to enter no value.

     

    In this case, you can use the If statement to check for =$form1.state.number1.value === 'undefined' and error as needed. If a value is present, you can then check its range: =$form1.state.number1.value.numeric >= 0 && $form1.state.number1.value.numeric <= 600 and error as necessary.

     

    Take a look at the attached workflow for one method. You can also use Regular Expression Matches activity to achieve this.

     

    Thanks, Stefan

    0
  • Permanently deleted user

    Thank you Stefan!

    I think I was missing the ".numeric" part of the expression to compare it to another number value. Also didn't realize you could combined statements using the &&

     

    Is there somewhere in the help that defines how to write some of these statements?

     

    Thanks again for your help!!

    Tom

    0
  • Stefan Schweigert

    No problem, glad that I was able to help!

     

    We don't currently, but I'll create a suggestion to improve our documentation around this.

    0
  • Permanently deleted user

    I have another question around this same issue.

    I have been testing what you uploaded, using my own data, and I think I have come to the conclusion that when you have a number field it does not recognize it as being 'undefined' in any state.

    I tweaked what you sent so it should error if the field is left undefined, but it does not error.

     

    What I am actually trying to do at the moment is on a change event show another field if the first numeric field is filled out. Which i thought i had, but if the user fills it out then removes the numbers in it the second field should blank out then disappear. Using the statement below I think should work but does not.

     

    =$form1.state.number1.value === 'undefined'

     

    Is there a different way to test if a number field on a form is blank?

     

    Tom

    0
  • Stefan Schweigert

    Hello Thomas,

     

    Thanks for catching my syntax error, this is the correct way to check for undefined:

     

    =$form1.state.number1.value === undefined

     

    Stefan

    0

Du måste logga in om du vill lämna en kommentar.