Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

try this , modify for your need

C#
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);
 
Share this answer
 
Comments
[no name] 23-Jan-14 2:34am    
i want to use Jquery prepend() for the same.
i have the value which is already present in textbox.
values are like=36.22,36.56,56.22 .But some values are different as like 3.23,4.36.
So according to the format textbox value include 5 character means 36.22. if it is 4 character
like 3.23 it should set 0 before 3.23.For that i want to do with Prepend ().
As i have the code $('#txtRate1').val(customerLoanOcr.Loan1Intrst);

Thanks
Harshal.
[no name] 23-Jan-14 2:36am    
i have try this but no use
if (customerLoanOcr.Loan1Intrst == 4) {
$('#txtRate1').val(customerLoanOcr.Loan1Intrst).prepend('0');
}
else {
$('#txtRate1').val(customerLoanOcr.Loan1Intrst)
}
Karthik_Mahalingam 23-Jan-14 3:09am    
try this
var val = customerLoanOcr.Loan1Intrst;
var left = ('0' + val.split('.')[0])
left = left.substring(left.length - 2);
var right = val.split('.')[0];
var output = left + '.' + right;
$('#txtRate1').val( val);
[no name] 23-Jan-14 3:24am    
Thanks for the reply .
Sorry to say but it dont work.I am getting the value but if vale something like this 3.26
so i want 0 before 3.26 ie:-03.26 . i am not getting 0 before 3.Please Help.

Very Thanks
Harshal
Karthik_Mahalingam 23-Jan-14 4:13am    
sorry its
$('#txtRate1').val( output);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900