Copy link to clipboard
Copied
I have a field labeled itemNo defined as nvarchar 50 in table on sql server.
On the form, when they enter the itemNo, I need it to be 00010, alsways 5 digits with leadgin zeros, because I have to use that as an exact match in a search later on. Most of the time, they only enter 10 and my search fails.
How do I automatically add the leading zeros to the form variable.I suppose I can check for length and insert it with the leading zeros, but I am using the form variable to check, so I would like that to have leading zeros.
Thanks
Copy link to clipboard
Copied
If the values is always numeric, one option is to use NumberFormat() with a mandatory digit mask
#NumberFormat(form.someValue, "00000")#
Copy link to clipboard
Copied
another way
newnum = right("00000" & oldnumber, 5);
Copy link to clipboard
Copied
<cfset nextid=NumberFormat(nextid,"0000")>
refer
http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functa48.htm