如何为十进制值前置数字。 [英] How Do I Prepend The Digits For Decimal Value .

查看:80
本文介绍了如何为十进制值前置数字。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Team,



我写了这段代码

$('#txtRate1')。val(customerLoanOcr.Loan1Intrst);



在txtRate1中,我得到的值为32.25,根据我们的要求是好的。

但有时我得到的值如3.25这是创造问题。值得消失。

所以对于3.25我想要预先设置值,以便在txtRate1文本框中我们可以看到value.it可以在3.25之前得到零

例如:03.25。我需要这样的。好友帮助



谢谢

Harshal Raut

Hello Team,

I have written this code
$('#txtRate1').val(customerLoanOcr.Loan1Intrst);

In txtRate1 i am getting the value as 32.25 which is fine as per our requirement.
but sometimes i am getting the value like 3.25 which is creating the problem.value getting disappear.
so for 3.25 i want to prepend the value so that in txtRate1 textbox we can see the value.it is ok to have a zero before 3.25
for example:03.25.I need it like this.Kindly help

Thanks
Harshal Raut

推荐答案

('#txtRate1')。val(customerLoanOcr.Loan1Intrst);



在txtRate1中,我得到的值是32.25这是按照我们的要求罚款。

但有时候我得到的值就像3.25那样造成问题。值得消失。

所以对于3.25我想要将值添加到txtRate1文本框中我们可以看到value.it可以在3.25

之前得到零例如:03.25。我需要这样的。好友帮助



谢谢

Harshal Raut
('#txtRate1').val(customerLoanOcr.Loan1Intrst);

In txtRate1 i am getting the value as 32.25 which is fine as per our requirement.
but sometimes i am getting the value like 3.25 which is creating the problem.value getting disappear.
so for 3.25 i want to prepend the value so that in txtRate1 textbox we can see the value.it is ok to have a zero before 3.25
for example:03.25.I need it like this.Kindly help

Thanks
Harshal Raut


试试这个,根据需要进行修改



try this , modify for your need

var val = '74.44';
       var left = ('0' + val.split('.')[0])
       left = left.substring(left.length - 2);
       var right = val.split('.')[0];
       var output = left + '.' + right;
       alert(output);


这篇关于如何为十进制值前置数字。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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