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);
Advertisements
Categories: SharePoint
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: