Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Javascript-Add currency to your given number.
WhatsApp
Ghanashyam Nayak
4y
6.3
k
0
0
25
Blog
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
>
<html>
<head>
<title>Sample Code</title>
<script type=
"text/javascript"
>
function
AddCurrency(MyString)
{
var
objRegex = /^-?[0-9]+\.[0-9]+$/;
if
(objRegex.test(MyString))
{
objRegex.compile(
'^-'
);
if
(objRegex.test(MyString))
{
MyString =
'('
+ MyString.replace(objRegex,
' '
) +
')'
;
}
alert(
'$'
+ MyString);
}
else
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=
"Add Currency"
name=
"btnAddCurrency"
onClick=
"AddCurrency(txtOriginal.value);"
/>
</FORM>
</body>
</html>
Javascript-Add currency to your given number.
Up Next
Javascript-Add commas into your given number after every three digits.
Ebook Download
View all
Frontend Developer Interview Questions and Answers
Read by 938 people
Download Now!
Learn
View all
Membership not found