justinmind-logo
 
Upvote 2

Autojump for number fields

Answered Victor Conesa 12 years ago

I am trying to implement an "autojump" to numeric fields so that the field only allows a certain number of digits and then the focus automatically jumps to the next field. This is commonly implemented in numeric fields such as Social Security field, Birthday fields and Phone Number field. Is this possible in Justinmind? Can you limit a field to a certain number of characters? Can you set a field to move the focus to the next field when that number has been exceeded? In a related question, can you enable a field to accept only numbers?

Replies (12)
photo
1

You can enable a field to accept only numbers using a regular expression and the 'on key pressed' event. You can use also the 'on key pressed' event to do the 'autojump' as well. How can you do it? Select the field and create an 'on key pressed' event. Then create a condition that checks if the value is not a number using the regular expression function. Create an 'set value' action that changes the value of the field if the value is not a number so that it removes the last character from the input field (use the 'substring' function').

photo
1

I am a little lost here. Can you post an example?


And this solution appears to deal with the numbers only and the auto-jump, but it does not appear to deal with the core issue of setting a field to accept a maximum number of characters. Without that, I am not sure the rest matters.

photo
1

Here you go http://justinmind.s3.amazonaws.com/re.... It works better in the exported HTML.

photo
1

Sorry, when I click the link you gave, I just see a bunch of characters.

photo
1

Weird. Could you send me a message so I can send you the vp file by email?

photo
1

I looked at the character limit vp posted. That made sense but that isn't what I want to do. I searched to see if someone had built an expression that does what was talked about here to validate the characters are numbers and not text. I would like to use this on an age and phone number text input fields I have. I figure it's easy but I didn't see how to do it in the expression builder. A tip or a sample for this would be great, thanks!

photo
1

Great, thanks.

photo
1

Ok, so I never knew those were there for email, phone, etc. Those will be really helpful. But here's a small complaint, now it validates (I just added "N" for not) that if not a phone number it returns an error. But for some reason the only form it accepts is "2565665698". It returns an error if it's a 7 digit number, or if there are any hyphens in it. Which according to the help shouldn't happen. I did not alter the algorithm. I double checked to make sure it matched. The only difference was it was missing the "/" on either end of it, but I figured that must be normal. Thoughts? I've thought about altering it myself but thought I'd check with you guys first before doing that. Thanks!

photo
1

The 'is phone' regular expression is just an example of an expression. You can http://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation

photo
1

Ah, I'll try some of the others and see what kind of luck I have, thanks!

photo
1

Please make it easier put limitation settings on properties tab for input field

Leave a Comment
 
Attach a file