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!

urgent regular expression problem

Status
Not open for further replies.

fgeorge

Programmer
Jun 28, 2002
76
NG
can someone urgently show me a regular expression to validate the format dd/mmm/yyyy?
thanks
 
u r using one textfield to capture the data?
try this:
if((!window.document.form1.sjoin.value.match(/^[\d]{1,2}[\/|.][\d]{2}[\/|.][\d]{2,4}$/)) || (window.document.form1.sjoin.value.match(/[\/.][\d]{3}$/)))


note form1 is form name and sjoin is the field name. it will allow u to enter date of type:
dd/mm/yy
or
dd/mm/yyyy



Known is handfull, Unknown is worldfull
 
thanks..
but what i want to match is dd/mmm/yyyy

not dd/mm/yy
 
Code:
/^\d{2}\/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\/[\d]{4}$/
maybe? It won't really validate it though, just check the format. Big difference.

Aynways, HTH.

(Do you maybe want spaces rather than slashes in there?)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top