Copy link to clipboard
Copied
required output if field 1 is 150 field 2 show "one fifty numbers only"
field 2 validation script
function ConvertToHundreds(num)
{
aTens = [ "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
aOnes = [ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen",
"Eighteen", "Nineteen" ];
var cNum, nNum;
var cWords = "";
num %= 1000;
if (num > 99) {
/* Hundreds. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aOnes[nNum] + " Hundred";
num %= 100;
if (num > 0)
cWords += " "
}
if (num > 19) {
/* Tens. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aTens[nNum - 2];
num %= 10;
if (num > 0)
cWords += " ";
}
if (num > 0) {
/* Ones and teens. */
nNum = Math.floor(num);
cWords += aOnes[nNum];
}
return cWords;
}
function ConvertToWords(num)
{
var aUnits = [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ];
var cWords = (num >= 1 && num < 2) ? " Numbers Only" : " Numbers Only";
var nLeft = Math.floor(num);
for (var i = 0; nLeft > 0; i++) {
if (nLeft % 1000 > 0) {
if (i != 0)
cWords = ConvertToHundreds(nLeft) + " " + aUnits[i - 1] + " " + cWords;
else
cWords = ConvertToHundreds(nLeft) + " " + cWords;
}
nLeft = Math.floor(nLeft / 1000);
}
num = Math.round(num * 100) % 100;
if (num > 0)
cWords += ConvertToHundreds(num) + " "
else
cWords += " ";
return cWords;
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
field 2 custom calculation script
event.value = "";
var f = this.getField("No of Bonds A Minimum 2 Maximum 500In Numbers");
if(f.valueAsString != "") {
event.value = ConvertToWords(f.value);
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
required output if field 3 is 15000072.89 field 4 show "One crore fifty lakhs seventy two rupeese and eight nine pise only"
field 4 validation script given
function ConvertToHundreds(num)
{
aTens = [ "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
aOnes = [ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen",
"Eighteen", "Nineteen" ];
var cNum, nNum;
var cWords = "";
num %= 1000;
if (num > 99) {
/* Hundreds. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aOnes[nNum] + " Hundred";
num %= 100;
if (num > 0)
cWords += " "
}
if (num > 19) {
/* Tens. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aTens[nNum - 2];
num %= 10;
if (num > 0)
cWords += " ";
}
if (num > 0) {
/* Ones and teens. */
nNum = Math.floor(num);
cWords += aOnes[nNum];
}
return cWords;
}
function ConvertToWords(num)
{
var aUnits = [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ];
var cWords = (num >= 1 && num < 2) ? "Only" : "Only";
var nLeft = Math.floor(num);
for (var i = 0; nLeft > 0; i++) {
if (nLeft % 1000 > 0) {
if (i != 0)
cWords = ConvertToHundreds(nLeft) + " " + aUnits[i - 1] + " " + cWords;
else
cWords = ConvertToHundreds(nLeft) + " " + cWords;
}
nLeft = Math.floor(nLeft / 1000);
}
num = Math.round(num * 100) % 100;
if (num > 0)
cWords += ConvertToHundreds(num) + " ";
else
cWords += " ";
return cWords;
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
field 4 custom calculation script
event.value = ConvertToWords(this.getField("field 3").value);
Copy link to clipboard
Copied
Is this a working solution you are sharing with us, or a question? If it is a question, what is the question, please?
Copy link to clipboard
Copied
its a question
question 1
i am created four field and given this javascript under custom validation script in 2nd and 4 th java script respectively but it is not working properly either both field showing " Numbers Only" or "Rupees only" i need both work in different field
Quistion 2
i need to convert this to thousand ten thousand one lakhs tenlakhs crore currency format from
Thousand", "Million", "Billion", "Trillion", "Quadrillion" format
Copy link to clipboard
Copied
Question 1: the code you posted seems to have been written as a calculation script, not a validation script. You need to write a new script, I think.
Question 2: you will need to understand and rewrite the code to accomodate these extra word meanings.
Copy link to clipboard
Copied
question number 1 explanation
i given custom calculation script in
event.value = "";
var f = this.getField("No of Bonds A Minimum 2 Maximum 500In Numbers");
if(f.valueAsString != "") {
event.value = ConvertToWords(f.value);
}
and then given custom calculation script in Field 4 also
event.value = ConvertToWords(this.getField("field 3").value);
then the function ConvertToWordsConvertToWords written in validation script this is separate program in different field as given the details above one should end with numbers only and other should show rupeese only both re working individually field 4 working correctly if i delete field 2 validation script and field 2 working correctly if i delete field 4 validation script both validation script starting as given below
function ConvertToHundreds(num)
{
Find more inspiration, events, and resources on the new Adobe Community
Explore Now