|  Topic awaiting preservation: Using Regular Expressions to recieve date from user (Page 1 of 1)  | |
|---|---|
| Bipolar (III) Inmate From: Juneau, Alaska |  posted 11-30-2005 01:21 I'm not entirely sure what is wrong with my Reg Exp. I'm trying to receive dates in "mm/dd/yyyy" format, but it doesn't seem to matter what is submitted. code: birthdatepattern = new RegExp("/^[01][0-9]\/[0123][0-9]\/[012][0-9][0-9][0-9]$/");
    var match = birthdatepattern.test(usersubmittedbirthdate);
  	
  	if (match = false) {
  		
  		alert('This match is false.');  		
  		
  	} else {
          
           Result B
           ....
        }
 | 
| Bipolar (III) Inmate From: Umeå, Sweden |  posted 11-30-2005 02:05 quote: You're assigning the value false, not comparing to (which isn't needed at all). code: var
    pass=[false,'01/4/1999','11/01/2083','1/31/1900'],
    fail=[false,'0/12/1999','13/12/1999','1/1/1','09/00/1900','9/32/1999','9/23/1893'],
    re=/^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/(19\d\d|20\d\d)$/,
    t;
while(t=pass.pop())
    alert(t+'\n'+re.test(t));
while(t=fail.pop())
    alert(t+'\n'+re.test(t));
 | 
| Bipolar (III) Inmate From: Juneau, Alaska |  posted 11-30-2005 22:49 quote: 
 quote: 
 |