Forcing entry of decimal points in a field

Hi all

Does anyone know how to force a user to enter in a number in a decimal
point format in an x-form- that is, force them to enter 8.0 instead of 8
(not just having it be converted after the fact)?

Thank you

Steve

don’t think this is currently possible.

··· On Tue, Feb 1, 2011 at 4:10 AM, Steve Ollis wrote:

Hi all

Does anyone know how to force a user to enter in a number in a decimal
point format in an x-form– that is, force them to enter 8.0 instead of 8
(not just having it be converted after the fact)?

Thank you

Steve

is regexp validation supported in CC/JR? that could do it.

··· On Tue, Feb 1, 2011 at 9:05 PM, Drew Roos wrote:

don’t think this is currently possible.

On Tue, Feb 1, 2011 at 4:10 AM, Steve Ollis steve.ollis@gmail.com wrote:

Hi all

Does anyone know how to force a user to enter in a number in a decimal
point format in an x-form– that is, force them to enter 8.0 instead of 8
(not just having it be converted after the fact)?

Thank you

Steve

that might work, but probably not. the regex validation is meant to work on
text answers. so if you use a text question, you won’t have the numeric
keyboard, and entering numbers will be very cumbersome (or you’ll have to
train the users to change the input mode). if you were to use regex
validation on a numeric question, it will convert the numeric answer to text
before validation, but you don’t have much control over how this conversion
takes place. for example, even if you enter ‘8.0’, this might get converted
to text as ‘8’, and the validation would complain, even though they entered
a decimal point.

··· On Wed, Feb 2, 2011 at 2:28 AM, Jonathan Payne wrote:

is regexp validation supported in CC/JR? that could do it.

On Tue, Feb 1, 2011 at 9:05 PM, Drew Roos droos@dimagi.com wrote:

don’t think this is currently possible.

On Tue, Feb 1, 2011 at 4:10 AM, Steve Ollis steve.ollis@gmail.comwrote:

Hi all

Does anyone know how to force a user to enter in a number in a decimal
point format in an x-form– that is, force them to enter 8.0 instead of 8
(not just having it be converted after the fact)?

Thank you

Steve

Yeah, unfortunately there are no numeric xpath datatypes which require
entry of a digit , so if you wanted to mandate anything about the input it
would have to be a string input with a regex.

-Clayton

··· On Wed, Feb 2, 2011 at 10:58 AM, Drew Roos wrote:

that might work, but probably not. the regex validation is meant to work on
text answers. so if you use a text question, you won’t have the numeric
keyboard, and entering numbers will be very cumbersome (or you’ll have to
train the users to change the input mode). if you were to use regex
validation on a numeric question, it will convert the numeric answer to text
before validation, but you don’t have much control over how this conversion
takes place. for example, even if you enter ‘8.0’, this might get converted
to text as ‘8’, and the validation would complain, even though they entered
a decimal point.

On Wed, Feb 2, 2011 at 2:28 AM, Jonathan Payne paynejd@gmail.com wrote:

is regexp validation supported in CC/JR? that could do it.

On Tue, Feb 1, 2011 at 9:05 PM, Drew Roos droos@dimagi.com wrote:

don’t think this is currently possible.

On Tue, Feb 1, 2011 at 4:10 AM, Steve Ollis steve.ollis@gmail.comwrote:

Hi all

Does anyone know how to force a user to enter in a number in a decimal
point format in an x-form– that is, force them to enter 8.0 instead of 8
(not just having it be converted after the fact)?

Thank you

Steve

Can we just add regexp to a numeric box? This might be useful for entering
lab values where you require sig figs?

··· On Wed, Feb 2, 2011 at 1:25 PM, Clayton Sims wrote:

Yeah, unfortunately there are no numeric xpath datatypes which require
entry of a digit , so if you wanted to mandate anything about the input it
would have to be a string input with a regex.

-Clayton

On Wed, Feb 2, 2011 at 10:58 AM, Drew Roos droos@dimagi.com wrote:

that might work, but probably not. the regex validation is meant to work
on text answers. so if you use a text question, you won’t have the numeric
keyboard, and entering numbers will be very cumbersome (or you’ll have to
train the users to change the input mode). if you were to use regex
validation on a numeric question, it will convert the numeric answer to text
before validation, but you don’t have much control over how this conversion
takes place. for example, even if you enter ‘8.0’, this might get converted
to text as ‘8’, and the validation would complain, even though they entered
a decimal point.

On Wed, Feb 2, 2011 at 2:28 AM, Jonathan Payne paynejd@gmail.com wrote:

is regexp validation supported in CC/JR? that could do it.

On Tue, Feb 1, 2011 at 9:05 PM, Drew Roos droos@dimagi.com wrote:

don’t think this is currently possible.

On Tue, Feb 1, 2011 at 4:10 AM, Steve Ollis steve.ollis@gmail.comwrote:

Hi all

Does anyone know how to force a user to enter in a number in a decimal
point format in an x-form– that is, force them to enter 8.0 instead of 8
(not just having it be converted after the fact)?

Thank you

Steve

having a function operate on the raw string value of a numeric question
would require serious changes to the form engine. as is, regex can operate
on a numeric question, but it will use the numeric value of the answer
converted to a string according to xpath’s type conversion rules. so ‘8.000’
=> ‘8.’. there is no way of knowing how many zeros were entered originally
(nor should there be, really, since the two values are equivalent). it kind
of sounds like you’re asking for an sql ‘decimal’-like datatype.

··· On Wed, Feb 2, 2011 at 6:07 PM, Jonathan Jackson wrote:

Can we just add regexp to a numeric box? This might be useful for entering
lab values where you require sig figs?

On Wed, Feb 2, 2011 at 1:25 PM, Clayton Sims csims@dimagi.com wrote:

Yeah, unfortunately there are no numeric xpath datatypes which require
entry of a digit , so if you wanted to mandate anything about the input it
would have to be a string input with a regex.

-Clayton

On Wed, Feb 2, 2011 at 10:58 AM, Drew Roos droos@dimagi.com wrote:

that might work, but probably not. the regex validation is meant to work
on text answers. so if you use a text question, you won’t have the numeric
keyboard, and entering numbers will be very cumbersome (or you’ll have to
train the users to change the input mode). if you were to use regex
validation on a numeric question, it will convert the numeric answer to text
before validation, but you don’t have much control over how this conversion
takes place. for example, even if you enter ‘8.0’, this might get converted
to text as ‘8’, and the validation would complain, even though they entered
a decimal point.

On Wed, Feb 2, 2011 at 2:28 AM, Jonathan Payne paynejd@gmail.comwrote:

is regexp validation supported in CC/JR? that could do it.

On Tue, Feb 1, 2011 at 9:05 PM, Drew Roos droos@dimagi.com wrote:

don’t think this is currently possible.

On Tue, Feb 1, 2011 at 4:10 AM, Steve Ollis steve.ollis@gmail.comwrote:

Hi all

Does anyone know how to force a user to enter in a number in a
decimal point format in an x-form– that is, force them to enter 8.0 instead
of 8 (not just having it be converted after the fact)?

Thank you

Steve

Agreed. It would make people’s xforms extremely datatype-safe for this kind
of procedure to work.

One option would be to allow for people to use XML to define their datatype
(as is structurally allowed in XForms), although that’s unlikely to get us
much.

The right answer is probably to regex a string box, and use a decimal()
wrapper when values want to treat it like a number. The unfortunate aspect
of that is the inability to guarantee that we can identify statically that
only numeric values are allowed, but we might be able to do so with the
pivot code I wrote earlier for Drew’s stuff.

For now, if anyone requires sig-figs, regex string is the only practical
solution.

-Clayton

··· On Wed, Feb 2, 2011 at 6:46 PM, Drew Roos wrote:

having a function operate on the raw string value of a numeric question
would require serious changes to the form engine. as is, regex can operate
on a numeric question, but it will use the numeric value of the answer
converted to a string according to xpath’s type conversion rules. so ‘8.000’
=> ‘8.’. there is no way of knowing how many zeros were entered originally
(nor should there be, really, since the two values are equivalent). it kind
of sounds like you’re asking for an sql ‘decimal’-like datatype.

On Wed, Feb 2, 2011 at 6:07 PM, Jonathan Jackson jjackson@dimagi.comwrote:

Can we just add regexp to a numeric box? This might be useful for
entering lab values where you require sig figs?

On Wed, Feb 2, 2011 at 1:25 PM, Clayton Sims csims@dimagi.com wrote:

Yeah, unfortunately there are no numeric xpath datatypes which require
entry of a digit , so if you wanted to mandate anything about the input it
would have to be a string input with a regex.

-Clayton

On Wed, Feb 2, 2011 at 10:58 AM, Drew Roos droos@dimagi.com wrote:

that might work, but probably not. the regex validation is meant to work
on text answers. so if you use a text question, you won’t have the numeric
keyboard, and entering numbers will be very cumbersome (or you’ll have to
train the users to change the input mode). if you were to use regex
validation on a numeric question, it will convert the numeric answer to text
before validation, but you don’t have much control over how this conversion
takes place. for example, even if you enter ‘8.0’, this might get converted
to text as ‘8’, and the validation would complain, even though they entered
a decimal point.

On Wed, Feb 2, 2011 at 2:28 AM, Jonathan Payne paynejd@gmail.comwrote:

is regexp validation supported in CC/JR? that could do it.

On Tue, Feb 1, 2011 at 9:05 PM, Drew Roos droos@dimagi.com wrote:

don’t think this is currently possible.

On Tue, Feb 1, 2011 at 4:10 AM, Steve Ollis steve.ollis@gmail.comwrote:

Hi all

Does anyone know how to force a user to enter in a number in a
decimal point format in an x-form– that is, force them to enter 8.0 instead
of 8 (not just having it be converted after the fact)?

Thank you

Steve