View Full Version : I want to put leading zero automatically

08-30-2005, 01: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

08-30-2005, 04:08 PM
While Len(Field) < 4
Field = "0" & Field
End While

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, 06: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.

08-30-2005, 06:12 PM
Exactly. The above loop will pad Field to four digits with zeroes.

09-02-2005, 07: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:

seraphicmortal :)