Hello

I am having some difficulties with number fields. One field we use to collect telephone numbers, which here in the UK all start with a leading zero however Kobo seems to strip this out and will save the value without the zero at the beginning. Is there a way to change this behaviour?

I also run a calculation based on my input data which is a currency, this calculation needs to display the results to two decimal places. I’ve tried various tricks but I cannot seem to find one that works, is this possible?

Thanks in advance

Hi Robert,

For your first query you will need to use a text field, to which you can add a regex constraint to make sure that only numbers are captured. For example it could be regex(.,’^([0-9]){14}$’). You can also set it up in such a way that it has to start with the UK indicator or else it isn’t accepted.

Another solution if you don’t like the fact that the number keypad doesn’t appear with a text type question would be to add the 0 in an extra calculation (not very clean but functional!)

For your second query, you can use the round() function in your calculation: round((${VALUE}),2).

Best,

Maeve

## ···

On Monday, October 23, 2017 at 10:36:16 AM UTC+1, Robert Fitzgerald wrote:

Hello

I am having some difficulties with number fields. One field we use to collect telephone numbers, which here in the UK all start with a leading zero however Kobo seems to strip this out and will save the value without the zero at the beginning. Is there a way to change this behaviour?

I also run a calculation based on my input data which is a currency, this calculation needs to display the results to two decimal places. I’ve tried various tricks but I cannot seem to find one that works, is this possible?

Thanks in advance

2 Likes

Hi Robert,

Another solution to your first question would be to make the phone number a "text" question, and then (in Kobo) set the Appearance as "numbers."

In XLSForm, you would write "numbers" in the Appearance column.

1 Like

Thank you for this idea, this works well for us

## ···

On Tuesday, 24 October 2017 00:33:38 UTC+1, Peter Smith wrote:

Hi Robert,

Another solution to your first question would be to make the phone number a “text” question, and then (in Kobo) set the Appearance as “numbers.”

In XLSForm, you would write “numbers” in the Appearance column.

1 Like

Hi Maeve

Thanks for the suggestions, for the phone numbers I’ve gone down the option of a text input which works fine for us.

With the rounding to two digits, I am struggling to get it to work. I have added the round code into the formula but it seems to be ignored and shows the same whether with or without.

The calculation I am using is:

round((${softcalc})*2.50,2)

``

Which for my test example gives an output of 25 instead of 25.00 as I would like it to show.

Can you advise why this may be?

## ···

On Monday, 23 October 2017 23:11:16 UTC+1, ma...@de-france.net wrote:

Hi Robert,

For your first query you will need to use a text field, to which you can add a regex constraint to make sure that only numbers are captured. For example it could be regex(.,’^([0-9]){14}$’). You can also set it up in such a way that it has to start with the UK indicator or else it isn’t accepted.

Another solution if you don’t like the fact that the number keypad doesn’t appear with a text type question would be to add the 0 in an extra calculation (not very clean but functional!)

For your second query, you can use the round() function in your calculation: round((${VALUE}),2).

Best,

Maeve

On Monday, October 23, 2017 at 10:36:16 AM UTC+1, Robert Fitzgerald wrote:

Hello

I am having some difficulties with number fields. One field we use to collect telephone numbers, which here in the UK all start with a leading zero however Kobo seems to strip this out and will save the value without the zero at the beginning. Is there a way to change this behaviour?

I also run a calculation based on my input data which is a currency, this calculation needs to display the results to two decimal places. I’ve tried various tricks but I cannot seem to find one that works, is this possible?

Thanks in advance

Hi Robert,

At first glance, your parenthesis are probably wrong depending what type of calculation you are trying to do (the example I had given earlier in the thread might not have been very clear!)-in your case I would probably use: round((${softcalc}*2.50),2)

Hope that helps.

Best,

Maeve

## ···

On Monday, January 8, 2018 at 2:29:57 PM UTC+1, Robert Fitzgerald wrote:

Hi Maeve

Thanks for the suggestions, for the phone numbers I’ve gone down the option of a text input which works fine for us.

With the rounding to two digits, I am struggling to get it to work. I have added the round code into the formula but it seems to be ignored and shows the same whether with or without.

The calculation I am using is:

round((${softcalc})*2.50,2)

``

Which for my test example gives an output of 25 instead of 25.00 as I would like it to show.

Can you advise why this may be?

On Monday, 23 October 2017 23:11:16 UTC+1, ma...@de-france.net wrote:

Hi Robert,

For your first query you will need to use a text field, to which you can add a regex constraint to make sure that only numbers are captured. For example it could be regex(.,’^([0-9]){14}$’). You can also set it up in such a way that it has to start with the UK indicator or else it isn’t accepted.

Another solution if you don’t like the fact that the number keypad doesn’t appear with a text type question would be to add the 0 in an extra calculation (not very clean but functional!)

For your second query, you can use the round() function in your calculation: round((${VALUE}),2).

Best,

Maeve

On Monday, October 23, 2017 at 10:36:16 AM UTC+1, Robert Fitzgerald wrote:

Hello

I am having some difficulties with number fields. One field we use to collect telephone numbers, which here in the UK all start with a leading zero however Kobo seems to strip this out and will save the value without the zero at the beginning. Is there a way to change this behaviour?

I also run a calculation based on my input data which is a currency, this calculation needs to display the results to two decimal places. I’ve tried various tricks but I cannot seem to find one that works, is this possible?

Thanks in advance

1 Like