View Single Post
Old 12-09-2012, 09:10 PM   PM User | #26
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Well, I will point out that my same regular expression could be used in JavaScript to validate the same dates.

Maybe a hacik?
Code:
		<input type="text" name="datedue" id="datedue" placeholder="12/31/2000" title="12/31/2000"
		 pattern="^(((0?[13578]|1[02])[.\/](0?[1-9]|[12]\d|3[01])|(0?[469]|11)[.\/](0?[1-9]|[12]\d|30))[.\/](19|20)\d\d)|((0?2[.\/](0?[1-9]|1\d|2[0-8])[.\/](19|20)([02468][1235679]|[13579][01345789]))|(0?2[.\/](0?[1-9]|1\d|2[0-9])[.\/](19|20)([02468][048]|[13579][26])))$" 
                 required autofocus
		 onchange="this.style.backgroundColor='lime';
                 if (! (new RegExp(this.getAttribute('pattern'),'i') ).test(this.value) ) 
                 { this.style.backgroundColor='pink';this.focus();}
                "
		/>
That works in IE, even. <grin/> (Redundant in other browsers, but so what?)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote