Regex is killing me

Im trying to use this regex to ensure a whole number is choosen (I thought it was working but I guess not)

/^\d[1-99]$/

for use in

function checkQty(value) {

if( !value.match(/^\d[1-99]$/)) {
	document.getElementById("Quantity_Error").innerHTML = "Must be a whole number from 1 to 99";
	document.getElementById("Quantity").focus();
} else {
	document.getElementById("Quantity_Error").innerHTML = "";
}
}

the problem can be seen at
http://fixmysite.us/Web_Programming_With_Javascriipt/Assignment7/

Thanks…

That regex would mean: any \digit character followed by [any character from 1-9 OR 9]. What you’re after is

/^\d{1,2}$/

which means: one to two digit characters.

You already got an answer to this question in another thread - Number range regex

1 Like

I thought this looked familiar.

thanks, sorry about that…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.