View Full Version : I want to put leading zero automatically
08-30-2005, 02:59 PM
I have one field in form and i want to put leading zero automatically like if someone put 1 it should write 0001 and if someone write 11 then 0011 but it should be leading zero automatic.
I appreciate quick reply
While Len(Field) < 4
Field = "0" & Field
I don't know if this is valid ASP (I don't know ASP and am judging from my long-ago knowledge of REALBasic), but that's the general idea of it.
08-30-2005, 07:01 PM
Its not i want to put only one zero. it can be one or two or three also.it depend on how many digits someone enters.
Exactly. The above loop will pad Field to four digits with zeroes.
09-02-2005, 08:56 AM
Hi amit1234! I'm also new to ASP...and similarly got the same problem.. :o
I found this code and this was a great help in solving that problem...
You need to do some itsy bitsy tweaking on it though if you want it to be automatic... =)
Hope it helps! :cool:
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.