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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegExp 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
I'm trying to create a regular expression that tests true when a figure entered into a field is 6 or less figures.

I've tried

var myReg1 = /\d{,6}/;

var myReg1 = /[0-9]{,6}/;

but it either doesnt allow less than 6 figures or always equates to false. Whats wrong with this?

Code:
function regExpAmountIs_valid( text ){
  var myReg1 = /\d{,6}/;
  alert(myReg1.test(text));
}

Matt
"Success is 10% inspiration, 90% last minute changes
 
mcowen,

Try this pattern?
[tt]
var myReg1 = /^\d{0,6}$/;
[/tt]
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top