custom_formatters/card_expiry.js
function limit(val, max) {
  if (val.length === 1 && val[0] > max[0]) {
    val = '0' + val;
  }

  if (val.length === 2) {
    if (Number(val) === 0) {
      val = '01';

    //this can happen when user paste number
  } else if (val > max) {
      val = max;
    }
  }

  return val;
}
function limit(val, max) {
  if (val.length === 1 && val[0] > max[0]) {
    val = '0' + val;
  }

  if (val.length === 2) {
    if (Number(val) === 0) {
      val = '01';

    //this can happen when user paste number
  } else if (val > max) {
      val = max;
    }
  }

  return val;
}
function limit ( val , max ) { if ( val . length === 1 && val [ 0 ] > max [ 0 ] ) { val = '0' + val ; } if ( val . length === 2 ) { if ( Number ( val ) === 0 ) { val = '01' ; //this can happen when user paste number } else if ( val > max ) { val = max ; } } return val ; }
This method limit val between 1 to max
val and max both are passed as string
This method limit val between 1 to max val and max both are passed as string