问题描述
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
推荐答案
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);
这篇关于如何为十进制值前置数字。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!