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

regex help

Status
Not open for further replies.

plork123

Programmer
Mar 8, 2004
121
GB


hi all, can someone show me a regular expression for this

01/07 (mm/yy) - first 2 have to be numbers, then followed by a slash then last 2 have to be numbers

the first set of 2 numbers cannot be greater then 12

thanks for any help
 
[tt]var rx=/^([1][0-2]|[0][1-9])\/\d{2}$/;[/tt]
 


i've got a reg ex that checks for nos only. i only put numbers in the input box but the code goes into the if statement and displays the alert. can someone shw me what i'm doing wrong? many thnaks

var value = field.value;

var numbers = /[^0-9]/;

if (!numbers.test(value))
{
alert ('in if');
return false;
}
 
>var numbers = /[^0-9]/;
[tt]var numbers = /[0-9]/;[/tt]
You won't go far by speculation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top