Not signed in (Sign In)

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorFormulate
    • CommentTimeMar 3rd 2011
     
    I am calculating a total by summing the (percentage) answers to a number of questions before it. Calculating is working fine, but I would like to be able to validate that the total is 100%. I tried setting the total question as mandatory (i.e. checking "answer required"), setting the format as custom regular expression with that regular expression being [1][0][0].

    This doesn't seem to actually do anything. The user can still enter percentages that sum to more (or less) than 100, and move freely to other questions and pages without the error message appearing.

    The form is at http://www.tfaforms.com/172547. Any ideas or help much appreciated.

    Thank you,
    Jessica Kerr
    Principal, Formulate Information Design
    http://formulate.com.au
    • CommentAuthorcbmartin
    • CommentTimeMar 3rd 2011 edited
     
    Jessica,

    You had it mostly right. The problem is with your regular expression. Try:

    ^10{2}$

    This is so...
    1 is at the beginning : ^1
    There are 2 instances of zero: 0{2}
    And that those instances are the last in the value string : $

    I believe that should work.

    FormAssebmly.com Support
    • CommentAuthorFormulate
    • CommentTimeMar 4th 2011
     
    Thank you, that does work.

    For what it's worth, I think my problem was just missing the start and end of string characters. It seems that

    ^[1][0][0]$

    works too. Maybe a little easier to read? But perhaps not conforming to regex best practice (which I'm not really familiar with).

    Appreciate the speedy and helpful response.

    Cheers
    Jessica Kerr
    Principal, Formulate Information Design
    http://formulate.com.au
    • CommentAuthordbuschho
    • CommentTimeMar 4th 2011
     
    Yup, Jessica, there's always more than one way to do everything in regex, for example, I think ^100$ would also have accomplished the goal.