v1
10/18/2022 by lmx -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
function isPattern(userInput) {
  if (typeof userInput !== 'string' || userInput.length !== 12) {
    return false;
  }
  for (let i = 0; i < userInput.length; i++) {
    let c = userInput[i];
    switch (i) {
      case 0:
      case 1:
      case 2:
      case 4:
      case 5:
      case 6:
      case 8:
      case 9:
      case 10:
      case 11:
        if (c < 0 || c > 9) return false;
        break;
      case 3:
      case 7:
        if (c !== '-') return false;
        break;
    }
  }
  return true;
}

function isPattern2(userInput) {
  return /^\d{3}-\d{3}-\d{4}$/.test(userInput);
}
delete caserun single casemove downdrag and drop case


ready



isPattern('123-123-1234')
isPattern('1231231234')
isPattern('123-123-123a')
isPattern('12a-123-1234')
delete caserun single casemove updrag and drop case


ready



isPattern2('123-123-1234')
isPattern2('1231231234')
isPattern2('123-123-123a')
isPattern2('12a-123-1234')
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN