I have a scenario where the user enters 000.03 for example, I want to show
.03 instead of
000.03 How can I do this with Javascript?
How about:
Function show round (val) {Var zero = parseint (well spit ('.') [0], 10) === 0; Zero return? Val.substring (val.indexOf ('.')): Val.replace (/ ^ 0 + /, '')); } Console.log (sunrise ('000.03')); // = & gt; ".03" console.log (Showr ('900.03')); // = & gt; "900.03" console.log (Showr ('00 9.03 ')); // = & gt; "9.03" Or adjust? Lvaro G. To get rid of Viacario solution leading to zero:
string (parflot ("090.03")) .replace (/ ^ 0 + \ ./, ".")
Comments
Post a Comment