<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN">
<html>
<head>
<title>Sample Code</title>
<script type="text/javascript">
function AddComma(MyString)
{
var objRegex = new RegExp('(-?[0-9]+)([0-9]{3})');
//Check For Criteria....
while(objRegex.test(MyString))
{
//Add Commas After Every Three Digits Of Number...
MyString
= MyString.replace(objRegex, '$1,$2');
}
alert(MyString);
}
</script>
</head>
<body bgcolor=#00ff00 alink=blue vlink=blue>
<FORM name="windowEvent">
Enter
String : <input type="text" name="txtOriginal"
/><br>
<input type="button" value="Remove Comma"
name="btnAddComma"
onClick="AddComma(txtOriginal.value);"
/>
</FORM>
</body>
</html> |