Checking for alpha AND numeric characters

I’m trying to show an error message when a field has both alpha AND numeric characters are in it. The field can only contain numeric chars - I already have the error working for the scenario where the user inputs just alpha characters; it’s pretty straightforward, that if text on widget is alpha, show the message. However, with just that case, the moment I put a number in the field (or if I start with numbers in the field, then put in an alpha char), the error does not come up. I’ve tried quite a few things to achieve this, with no result. I really thought I was on to something with a boolean statement (if this field contains a or b or c, etc. AND if this field contains 1 or 2 or 3, etc.) but it’s not working for me - the first letter and number combination (a and 1) work, but none of the others do. Here’s what I have (I’m just testing it with 1, 2, 3 and a, b, c to begin with) –

I’m not a programmer, rather a designer, not used to doing complex statements. I read some things in the forum about using the “or” operator. Am I off on my syntax? Is there some other totally different way to achieve this? Open to any and all suggestions!

@markrichterstl,

If you want to only accept numbers in an input field, the easiest solution is to set the Text Field widget to “Type: Number” (in the Properties panel or right-click widget and select Input Type > Number). Then only numbers will be accepted automatically, no need to craft an error message. It also has benefit of showing the browser’s numeric input method (spinner on desktops, numeric keyboard and/or spinner on mobile platforms.)

If you want to show an error message as feedback, see this .rp for a few methods.
NumberOnlyTextInput.rp (87.7 KB)

Your attempt to combine boolean “OR” statements with “AND” statements is interesting, but Axure just doesn’t allow this in a single conditional statement (at least that I’m aware of… I’m not sure why though.) In your case it is also overkill–you don’t want to have to do this with every possible alphabet character (plus capital letters!) However, if you did need to test for the presence of “a or b or c” and “1 or 2 or 3” you could do this, but you need to break up your tests for “this or that” and tests of “this and that” into two different conditionals. One way to do this is to execute a different action if the first test is true, then use that action to perform the second part of your test. A common approach is to move the widget by (0,0) so it doesn’t actually move anywhere but the OnMove event gets fired. This is demonstrated in the above .rp file, too.

Another, more robust method is to create separate widgets which can act as discrete functions. A common approach here is to create a blank dynamic panel with at least two states and change its state to “Next” (with wrapping to ensure it always gets changed) to execute the function. This is also demonstrated in the above .rp file. Just another way to set up and use a “hidden function” on a page to enable complex conditions.

2 Likes

Thank you so much! I think the one that works best for me is the example with “if text on This is numeric”, “Else if text on This is alpha” and “Else if text on This is alpha-numeric.” I actually started down this path originally, but it wasn’t working right - I think it’s because I was not using “Else if” statements. Some other really interesting approaches here, too. I’ve just recently been getting into more complex interactions, so this is great stuff! I greatly appreciate your help!

Mark