These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Numerical field validation

srikanthm
Registered: Dec 10 2009
Posts: 2

Hi,

I am new to Adobe development

1.In Adobe using script how to find out the entered field length.(example: user entered 123345.It should display length is 5)

2. How to take fisrt 3 characters in the Numeric field

Suggest some documentation for Adobe validations

Thanks
Srikanth

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
If you are accessing a numeric value, to keep leading zeros use the 'valueAsString' property if you want to drop the leading zeros, use 'toString()' method to the value. Numbers are not stored as character strings and unless you force them to a type of string value there string character length is zero.

Also if you convert to the the string values for numeric fields you can use the 'sbstr()' or 'substring()' JavaScript methods.

Some code you can try in the JavaScript console or in a button action:
console.show();var sNumber = '01234567890.987654321';console.println('String number: ' + sNumber)console.println('typeof: ' + typeof sNumber)console.println('length: ' + sNumber.length)var fNumber = Number(sNumber);console.println('floating point number: ' +fNumber)console.println('typeof: ' + typeof fNumber)console.println('length: ' + fNumber.length)var sFNumber = sNumber.toString();console.println('floating point number to string: ' +sFNumber)console.println('typeof: ' + typeof sFNumber)console.println('length: ' + sFNumber.length)console.println('substr')console.println('String nubmer: ' + sNumber.substr(0,3) );try {console.println('Floating point nubmer: ' + fNumber.substr(0,3) );} catch(e) {console.println(e.toString() );}console.println('substring");console.println('String nubmer: ' + sNumber.substring(0,3) );try {console.println('Floating point nubmer: ' + fNumber.substring(0,3) );} catch(e) {console.println(e.toString() );}

George Kaiser