Including zero in a digit constraint

Hi,
I have a constraint below for integers but its not accepting zero as a
number. How should I include zero?
For the others its working but when I input 00001 it cant accept.
Thanks

ken,

i don't understand what you are trying to do. something like
'constraint="regex(., '^[0-9]{5}$')' will match exactly five digits.

if you can give me examples of numbers you think are valid and numbers
which are invalid, i might be able to help.

yaw

··· On Mon, Aug 1, 2011 at 06:50, Ken Mwai wrote: > Hi, > I have a constraint below for integers but its not accepting zero as a > number. How should I include zero? > For the others its working but when I input 00001 it cant accept. > Thanks > relevant="(/data/similar=0)" constraint="regex(., '[0-9]{5}')" > jr:constraintMsg="This isn't a valid EA code.Enter 5 digits only"/> > > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en >

Yaw,

Just used the above constraint that you listed to ensure people enter
the correct number of digits for a phone number. This works perfectly
for entry of data in terms of limiting entry to digits. However
because the tel numbers start with a when I submit the form the tel
numbers all start with a 0 which is omitted when the data is submitted
e.g. 0999873646 becomes 999873646 in Aggregate and can be seen in ODK
collect if you go back a question. So

  1. Is there anyway to retain this additional digit?
  2. Is there anyway to prefix all submissions with the national
    dialling code e.g. 260 so that the submitted data is 260999873646?

Thanks for all your hardwork - ODK is excellent!

Dan

In 1.1.7 you can make the field a string, but give it an appearance=number
in the , and it'll restrict input to numbers plus a few other
characters (+.,-). It should also default to the number-keyboard for the
on-screen keyboard.

··· On Mon, Sep 5, 2011 at 7:15 AM, dj_bridges wrote:

Yaw,

Just used the above constraint that you listed to ensure people enter
the correct number of digits for a phone number. This works perfectly
for entry of data in terms of limiting entry to digits. However
because the tel numbers start with a when I submit the form the tel
numbers all start with a 0 which is omitted when the data is submitted
e.g. 0999873646 becomes 999873646 in Aggregate and can be seen in ODK
collect if you go back a question. So

  1. Is there anyway to retain this additional digit?
  2. Is there anyway to prefix all submissions with the national
    dialling code e.g. 260 so that the submitted data is 260999873646?

Thanks for all your hardwork - ODK is excellent!

Dan

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

About retaining the additional digit, does it work for you if you changed
the data type from integer to text?

··· On Mon, Sep 5, 2011 at 5:15 PM, dj_bridges wrote:

Yaw,

Just used the above constraint that you listed to ensure people enter
the correct number of digits for a phone number. This works perfectly
for entry of data in terms of limiting entry to digits. However
because the tel numbers start with a when I submit the form the tel
numbers all start with a 0 which is omitted when the data is submitted
e.g. 0999873646 becomes 999873646 in Aggregate and can be seen in ODK
collect if you go back a question. So

  1. Is there anyway to retain this additional digit?
  2. Is there anyway to prefix all submissions with the national
    dialling code e.g. 260 so that the submitted data is 260999873646?

Thanks for all your hardwork - ODK is excellent!

Dan

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

Thanks for the suggestions Daniel and Carl.

Daniel - changing the data type from integer to text does mean that
the leading 0 is retained. However the 10 digit constraint no longer
applies and letters can also be entered into the field.

Carl - I tried to implement your suggestion, but I think I am making
an error in the syntax. This is what I have:

and then in the body:

Am guessing that I have put the appearance=number in the wrong place?

Thanks for the help guys!

Sorry, it's "numbers" instead of "number".

··· On Mon, Sep 5, 2011 at 11:03 PM, dj_bridges wrote:

Thanks for the suggestions Daniel and Carl.

Daniel - changing the data type from integer to text does mean that
the leading 0 is retained. However the 10 digit constraint no longer
applies and letters can also be entered into the field.

Carl - I tried to implement your suggestion, but I think I am making
an error in the syntax. This is what I have:

and then in the body:

Am guessing that I have put the appearance=number in the wrong place?

Thanks for the help guys!

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

Carl,

Thanks for the reply. I tried changing it to numbers, but it doesn't
limit entry to numbers or to 10 characters.... Just to make sure - the
type in the node should = string or text?

Should be "string", but the regex should still work if it was correct
before.

··· On Mon, Sep 5, 2011 at 11:54 PM, dj_bridges wrote:

Carl,

Thanks for the reply. I tried changing it to numbers, but it doesn't
limit entry to numbers or to 10 characters.... Just to make sure - the
type in the node should = string or text?

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

Carl thanks for the reply.

OK so seems that the regexp isn't doing quite what I want it to do so
think that is where the problem is. What environment do people use for
testing regexp for ODK? Once I am confident the regexp is doing what I
want will then test the form again...

http://stackoverflow.com/questions/32282/regex-testing-tools

i use reggy on the mac.

··· On Wednesday, September 7, 2011, dj_bridges wrote:

Carl thanks for the reply.

OK so seems that the regexp isn't doing quite what I want it to do so
think that is where the problem is. What environment do people use for
testing regexp for ODK? Once I am confident the regexp is doing what I
want will then test the form again...

--
Post: opendatakit@googlegroups.com <javascript:;>
Unsubscribe: opendatakit+unsubscribe@googlegroups.com <javascript:;>
Options: http://groups.google.com/group/opendatakit?hl=en