Home > SharePoint > Javascript Tips and Tricks

Javascript Tips and Tricks

1. Replace all , in one Javascript string.

var totalAmount= "100,000,000,000";
var find= ","; //Replace the first , with the empty string
var replace="";
totalAmount= totalAmount.replace(find,replace);
alert(totalAmount);
var totalAmount2= "100,000,000,000";
var newFind=/,/g //Replace all , with empty string
totalAmount2= totalAmount2.replace(newFind,replace);
alert(totalAmount2);
Categories: SharePoint
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment