Conversion Number value to Words (String) using Java Script and Asp.net
In this article, we are convert the numeric value in
to words (string). Here we use a text box and a button to show the example, in
the textbox we validate that it takes only numeric value using java script. Basically
this code helps you to generate the bill and conversion the amount (numeric to
words).
If we are trying to some word or correct the we get
this type of error message.
Source code:-
<%@
Page Language="C#" AutoEventWireup="true" CodeFile="numbertostring.aspx.cs" Inherits="numbertostring"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var
specialKeys = new Array();
specialKeys.push(8); //Backspace
function
IsNumeric(e) {
var
keyCode = e.which ? e.which : e.keyCode
var
ret = ((keyCode >= 48 && keyCode <= 57) ||
specialKeys.indexOf(keyCode) != -1);
document.getElementById("error").style.display = ret ? "none" : "inline";
return
ret;
}
</script>
<style type="text/css">
.style1
{
font-size:
medium;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset style="width: 300px;">
<legend><strong><span class="style1">Convert Number to Words</span> </strong></legend>
<strong><span class="style1">Enter Value:</span></strong>
<asp:TextBox ID="txtnumber" runat="server" onkeypress="return IsNumeric(event);"
ondrop="return false;" onpaste="return false;" />
<br />
<br />
<asp:Button ID="btnclick" runat="server" Text="Convert" OnClick="btnclick_Click"
Style="height: 26px" /><br />
<br />
<label id="lbshow" runat="server" />
<span id="error" style="display: none">Please enter only numeric value
</span>
</fieldset>
</div>
</form>
</body>
</html>
Out Put:-
Conversion Number value to Words (String) using Java Script and Asp.net
Reviewed by NEERAJ SRIVASTAVA
on
2:50:00 PM
Rating:
Good post. Thanks for sharing.
ReplyDeleteRegards,
JAVA Training institutes in chennai