Monday, October 18, 2021

OIC - validate date format as MM-DD-YYYY

I use this regex for validating MM-DD-YYYY:

function isValidDate(subject){
  if (subject.match(/^(?:(0[1-9]|1[012])[\- \/.](0[1-9]|[12][0-9]|3[01])[\- \/.](19|20)[0-9]{2})$/)){
    return true;
  }else{
    return false;
  }
}

It will match only valid months and you can use / - or . as separators.

No comments:

Post a Comment

Featured Post

OIC - Moving a File using FTP connection now throws IO operation failed error

Error usecase: Moving a File using FTP connection now throws IO operation failed error. The integration has been working for weeks, with a f...