Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Someone change this Pattern...

Status
Not open for further replies.

Markh51

Programmer
May 20, 2003
81
GB
I have this pattern which checks to see if the entered value meets the criteria. The only problem I am having is that it allows you to enter values starting with 0.

Can someone change the following pattern to STOP 0's been entered at the beginning only.

^[0-9]{"+lmin+","+lmax+"}$

Thanks.
 
I use x = value.replace (/^0+/, '') to remove all leading 0 first. Hope this helps.
"When in doubt - move a pawn"
 
Markh51,
Do you want to strip the leading zero?
or Do you want to alert that it's invalid?
 
You might consider /^[1-9]{1}[0-9]{1,6}$/ this statement
limits your first occurence range to 1 then your second
occurence range is "1 not more than 6" for a total of
7 digits.

I would stay away from those variables inside the
{}brackets they do not work in my browser(IE).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top