Is it possible say a person enters an integer value 5 in a Textbox and automaticall a .00 is added in the end say 5.00
<asp:TextBox ID="txtAmountTransfer" runat="server" Width="55%" CssClass="right"></asp:TextBox>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
@CR41G14 is correct. .toFixed(2) is all you need.
As far as where and how, I would recommend using the change event on the input box as it is the least intrusive for the user. (The blur event would also not be unreasonable)
Since the value of the text field will be a string you will need to parse it as @Snuffleupagus points out. In your case, I would recommend parseFloat because then your field could potentially handle the user entering 5.2 which could become 5.20. (using parseInt you would end up with 5.00).
One additional note is recognizing that if the user types non-numeric characters (or really any value that will not parse) into the field, it will result in a display of NaN, which actually seems fairly reasonable in your case.
Using jQuery:
Similar example using native code: