Repeated Characters at End of Textbox
Hi all. I am new to Javascript and have limited understanding so far.
I have created a fillable pdf form to align with my check paper to type customized checks. I have written a javascript to convert the number typed into the 'Amount' box (i.e. $1,000.00) to text on the written amount line (i.e. ONE THOUSAND DOLLARS). I would like to this this format itself as "ONE THOUSAND DOLLARS***********************************" with the asterisks repeating until the end of the textbox which would obviously be a variable length depending on the length of the words needed. How might I code this and in what area would I write this code?
Thank you in advance!
Here is the coding I am currently using:
Document Javascript:
function Num2word(value) {
var fraction = Math.round(frac(value)*100);
var f_text = "";
if(fraction > 0) {
f_text = " AND "+convert_number(fraction)+" CENTS";
}
return convert_number(value)+" DOLLARS"+f_text+" ONLY";
}
function frac(f) {
return f % 1;
}
function convert_number(number)
{
if ((number < 0) || (number > 999999999))
{
return "NUMBER OUT OF RANGE!";
}
var Gn = Math.floor(number / 10000000); /* million */
number -= Gn * 10000000;
var kn = Math.floor(number / 100000); /* thousand */
number -= kn * 100000;
var Hn = Math.floor(number / 1000); /* thousand */
number -= Hn * 1000;
var Dn = Math.floor(number / 100); /* Tens (deca) */
number = number % 100; /* Ones */
var tn= Math.floor(number / 10);
var one=Math.floor(number % 10);
var res = "";
if (Gn>0)
{
res += (convert_number(Gn) + " MILLION");
}
if (kn>0)
{
res += (((res=="") ? "" : " ") +
convert_number(kn) + " THOUSAND");
}
if (Hn>0)
{
res += (((res=="") ? "" : " ") +
convert_number(Hn) + " THOUSAND");
}
if (Dn)
{
res += (((res=="") ? "" : " ") +
convert_number(Dn) + " HUNDRED");
}
var ones = Array("", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX","SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN","FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN","NINETEEN");
var tens = Array("", "", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY","SEVENTY", "EIGHTY", "NINETY");
if (tn>0 || one>0)
{
if (!(res==""))
{
res += " AND ";
}
if (tn < 2)
{
res += ones[tn * 10 + one];
}
else
{
res += tens[tn];
if (one>0)
{
res += ("-" + ones[one]);
}
}
}
if (res=="")
{
res = "zero";
}
return res;
}
Then I have this coded in Custom Calculation Script:
var val = this.getField("Amount").valueAsString;
if (val == ""){
event.value = ""
}else if (val != ""){
event.value = Num2word(val);
}
