Dojo:如何从值中删除逗号 [英] Dojo: how to remove comma from value

查看:136
本文介绍了Dojo:如何从值中删除逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有这个Dijit数字微调:

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>

此输入失去焦点后,会添加一个逗号。如何防止这个逗号显示?也就是说,我不想要2,011而是2011。

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.

谢谢!
Eric

Thanks! Eric

推荐答案


简单的答案是添加 pattern:'# '到您的约束对象。

pattern属性允许您指定如何显示数字数据。 这里是dojo参考数字模式的链接。整个页面对于格式化数字是非常有用的。

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>

这篇关于Dojo:如何从值中删除逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆