问题
I have this Dijit number spinner:
<div class="extra_field hide_on_load form_action_fy">
<label>Action Fiscal Year</label>
<input name="form_action_fy" id="form_action_fy"
data-dojo-type="dijit.form.NumberSpinner"
data-dojo-props="
value:@ViewBag.fy,
smallDelta:1,
largeDelta:1,
constraints:{min:2010,max:2020,places:0}"
/>
</div>
After this input loses focus, a comma is added. How do I prevent this comma from showing? That is, I don't want 2,011 but rather 2011.
Thanks! Eric
回答1:
The simple answer is to add pattern:'#'
to your constraints object.
The pattern property allows you to specify how you want your numeric data to be displayed. Here is a link to dojo's reference on number patterns. The whole page is pretty informative on formatting numbers.
Your example should end up looking something like this:
<div class="extra_field hide_on_load form_action_fy">
<label>Action Fiscal Year</label>
<input name="form_action_fy" id="form_action_fy"
data-dojo-type="dijit.form.NumberSpinner"
data-dojo-props="
value:2011,
smallDelta:1,
largeDelta:1,
constraints:{min:2010,max:2020,places:0,pattern:'#'}"
/>
</div>
来源:https://stackoverflow.com/questions/7996427/dojo-how-to-remove-comma-from-value