|
|
Javascript: Display a number in an input text as money. |
<SCRIPT type="text/javascript" LANGUAGE="JavaScript"><!--
function outputMoney(number) {
number=checkval(number);
return "$"+outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}
and for the field, I have...<input type="text" name="salary" onclick="this.value=checkval(this.value);this.select();" onBlur="this.value=outputMoney(this.value)">I'm expecting to have JS active for my in-office usage, so I'm not absolutely paranoid about JS being on or off. I'm also expecting to do something like <form onsubmit="salary.value=checkval(salary.value)">to make certain I've stored the proper type of number. The onclick part allows for the entire value to be highlighted-selected after removing $ and commas. Main js code copied from http://www.irt.org/script/723.htm wg-fomATgwyDOTorg | |
| [Append to This Answer] |
| Previous: |
|
| Next: |
|
| ||||||||