Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#3906 closed defect (duplicate)

dojo.number.regexp bug (affects dijit.form.NumberTextBox )

Reported by: guest Owned by: Adam Peller
Priority: high Milestone:
Component: General Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

You can see this behavior in dijit.form.NumberTextBox? as an example. If you set a constraints object to be places: "0,2", you should be able to enter any value with 0 to 2 decimal places. However, because of a bug in dojo.number.regexp, the decimal point is always required. here is the relevant code from dojo.number.regexp:

function(q){

var re = ""; if(q && (flags.places!==0)){

console.debug( "Typeof flags.places: " + typeof( flags.places ) + " and value is " + flags.places );

re = "\" + flags.decimal; if(flags.places == Infinity){

re = "(?:" + re + "\d+)?";

}else{

re += "\d{" + flags.places + "}";

}

} return re;

},

Notice how if flags.places != 0, it forces a decimal point. This needs to look for the possibility of two values for places, and put an optional decimal point if places contains a 0.

I bumped the severity on this, as for our app that uses all NumberTextBox?, it can't be used and we had to write our own subwidget.

Change History (3)

comment:1 Changed 12 years ago by Adam Peller

Owner: changed from anonymous to Adam Peller

Dup of #2864. My bad, I've been taking a long time getting around to implementing this. I should take it out of the docs if it doesn't work.

I think you can use JavaFormat?-like syntax on the pattern argument to achieve something close to this, but it should be simpler.

comment:2 Changed 12 years ago by Adam Peller

Resolution: duplicate
Status: newclosed

comment:3 Changed 12 years ago by Adam Peller

(In [10086]) Fix parse/regexp with places ranging from 0 to n: "0,n". Fixes #2864, Refs #3906

Note: See TracTickets for help on using tickets.